https://github.com/kosukesaigusa/code_generation_samples
💙 A collection of sample packages for code generation in Dart, featured in FlutterKaigi 2023
https://github.com/kosukesaigusa/code_generation_samples
code-generator dart dart-build-system dartlang source-gen
Last synced: 4 months ago
JSON representation
💙 A collection of sample packages for code generation in Dart, featured in FlutterKaigi 2023
- Host: GitHub
- URL: https://github.com/kosukesaigusa/code_generation_samples
- Owner: kosukesaigusa
- License: mit
- Created: 2023-10-24T11:45:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-25T07:22:12.000Z (over 2 years ago)
- Last Synced: 2025-06-02T18:59:56.755Z (about 1 year ago)
- Topics: code-generator, dart, dart-build-system, dartlang, source-gen
- Language: Dart
- Homepage: https://flutterkaigi.jp/2023/sessions/d9cc75af-a3a2-4d0e-af6c-f12aa143ba4c
- Size: 413 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# code_generation_samples
Welcome to `code_generation_samples`, a suite of packages that demonstrate various code generation techniques in Dart and Flutter. This repository is designed as an educational tool to help developers learn how to simplify and automate tasks through the use of code generation.
Additionally, this collection is featured as part of a presentation at FlutterKaigi, a renowned Flutter conference taking place in Japan on November 10th, 2023.
## Packages Included
This repository includes the following packages, each tailored for a specific code generation scenario:
This repository includes the following packages, each tailored for a specific code generation scenario:
- `copy_builder`: A basic builder package that generates duplicate files for all input files.
- `copy_builder_annotation`: Provides the `@Copy` annotation, which is recognized by `copy_builder_for_annotation`.
- `copy_builder_for_annotation`: An advanced version of `copy_builder` that targets files marked with `@Copy` annotations.
- `from_json_generator`: A builder that generates a `fromJson` method for classes decorated with annotations.
- `from_json_generator_annotation`: Supplies annotations that drive the behavior of `from_json_generator`.
## Quick Start
To see code generation in action, run the following commands in the `copy_builder`, `copy_builder_for_annotation`, and `from_json_generator` package directories. The generated files can be found within the `test/helper` directories of each package.
```sh
dart pub get
dart run build_runner build --delete-conflicting-outputs