brick
brick copied to clipboard
`build_runner` fails when flutter formatter breaks lines after long class names
In packages/brick_build/lib/src/builders/model_dictionary_builder.dart:67, the code uses a simple string match to find class declarations:
entry.value.contains('class ${annotation.element.name} ')
This fails when Flutter's formatter formats long class declarations and breaks the line after the class name: Example that fails:
// Before formatting (works)
class VeryLongClassNameThatExceedsTheEightyCharacterLimit extends SomeBaseClass {
// ...
}
// After formatting (fails)
class VeryLongClassNameThatExceedsTheEightyCharacterLimit
extends SomeBaseClass {
// ...
}
The space after the class name is replaced with a newline, causing the contains check to fail and the build to break with an error like:
StateError: Bad state: No element
It's not a critical issue, when one knows it's there, nevertheless it's annoying in codebase which uses formatter, linter and build_runner.