fluttercode-generationproject-managementbuild-runner

Use of code generation in flutter for production code among a team?


Is it possible to specify a single file to flutter package pub run build runner?


Solution

  • From the build_runner build --help output:

    --build-filter                  An explicit filter of files to build.
                                        Relative paths and `package:` uris are
                                        supported, including glob syntax for paths
                                        portions (but not package names).
    

    There is an example in their changelog:

    Example: The following would build and serve the JS output for an application, as well as copy over the required SDK resources for that app:

    pub run build_runner serve \
      --build-filter="web/main.dart.js" \
      --build-filter="package:build_web_compilers/**/*.js"
    

    https://pub.dev/packages/build_runner/changelog#170