If I use the following code in pubspec.yaml file, then the build_runner generates code but if I put it in the build.yaml file, then the code is not generated for fromJson and toJson.
targets:
$default:
builders:
json_serializable:
enabled: true
generate_for:
include:
- lib/foo.dart
I also want to know, whether I include (or not include) any files above, the code takes same amount of time to generate. So, how can I then generate the code for a specific file/directory, like first generate for foo.dart and later on I want to generate code for bar.dart keeping foo.dart and foo.g.dart intact.
If you are placing this code in
build.yamlthen yes,build_runneruse it as configuration and will generate a files that you include in your config. If you are placing this code inpubspec.yamlfilebuild_runnerwill not use it becausepubspec.yamldoesn't config file forbuild_runner.When you are working with
build_runneryou can listend and rebuild any changes automatically withwatchargument: