Dart `build_config` rename `buildStep.inputId` file

Issue

I want to rename (not just the extension) a file in my Builder. Is there any reason I shouldn’t just create my own File based on buildStep.inputId and write to the file?

Solution

If you do this then lots of weird things will happen:

  • It will cause a new build (the build system will think you just manually created a file)
  • Dependencies get all weird – that file will now be available to be consumed by any other builder (even ones that ran before it). This could cause infinite loops or other weirdness.
  • Your builder won’t be portable to bazel or other build system integrations outside of build_runner
  • We may in the future block you from doing this entirely

Basically, you would be circumventing the whole build system, and the behavior becomes undefined.

Answered By – Jake MacDonald

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *