Skip to content

Commit e575e1e

Browse files
authored
docs(flutter-freezed): document build_runner + amplify_flutter native-assets workaround (#10975)
1 parent 1cb0310 commit e575e1e

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎website/content/docs/guides/flutter-freezed.mdx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ export default config
218218
npm run generate
219219
```
220220

221+
## Troubleshooting
222+
223+
### `build_runner` fails when the project also depends on `amplify_flutter`
224+
225+
After generating your Freezed-annotated models, you still need to run Freezed's own code generation
226+
step (`dart run build_runner build` or `flutter pub run build_runner build`) to produce the
227+
`.freezed.dart`/`.g.dart` files. If your Flutter project also depends on `amplify_flutter`, this step
228+
can fail while `build_runner` tries to compile its build script.
229+
230+
This isn't a bug in `flutter-freezed` or GraphQL Code Generator. `amplify_flutter` transitively
231+
depends on `sqlite3` and `jni`, both of which declare Dart's
232+
[Native Assets ("build hooks")](https://github.com/dart-lang/native) feature. `build_runner` compiles
233+
its build script into a native (AOT) executable, and currently fails outright whenever any dependency
234+
in the graph declares a build hook — tracked upstream at
235+
[dart-lang/native#2792](https://github.com/dart-lang/native/issues/2792).
236+
237+
**Workaround:** run `build_runner` in JIT mode instead of compiling an AOT snapshot:
238+
239+
```sh
240+
dart run build_runner build --no-precompile
241+
```
242+
243+
This is a temporary workaround until the underlying incompatibility between `build_runner` and Dart's
244+
native-assets tooling is resolved upstream.
245+
221246
## Configuring the plugin
222247

223248
To configure the plugin, you need to first understand how to use Patterns to configure specific

0 commit comments

Comments
 (0)