This directory contains testable code samples used in the flutter_it documentation site.
All code samples in the documentation are extracted from these Dart files to ensure they:
- Compile correctly
- Follow best practices
- Stay up-to-date with API changes
code_samples/
├── lib/
│ ├── get_it/ # get_it examples
│ ├── watch_it/ # watch_it examples
│ ├── command_it/ # command_it examples
│ └── listen_it/ # listen_it examples
├── test/ # Tests that verify samples compile
└── pubspec.yaml # Dependencies
cd docs/code_samples
flutter testcd docs/code_samples
flutter analyzeUse VitePress code import syntax to include samples in markdown:
<!-- Import entire file -->
<<< @/../../code_samples/lib/get_it/basic_usage.dart
<!-- Import specific lines -->
<<< @/../../code_samples/lib/get_it/basic_usage.dart{10-20}
<!-- Import with region markers -->
<<< @/../../code_samples/lib/get_it/basic_usage.dart#setup- Create a new
.dartfile in the appropriatelib/subdirectory - Write compilable code with proper imports
- Add tests in
test/directory if needed - Reference the file in documentation markdown
- Run
flutter testto verify it compiles