FlutterGen / flutter_gen

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.
https://pub.dev/packages/flutter_gen
MIT License
1.44k stars 142 forks source link

Null safety support for generated files #75

Closed mark-nicepants closed 3 years ago

mark-nicepants commented 3 years ago

When I run the generator against a project with sdk constraints set to a version with nullability on (>=2.12-0-0) I expect that the generated code is compatible with the null safety features. It is not at the moment.

I created a bash script workaround that will add the @dart=2.10 comment on top.

#!/bin/bash

fluttergen

sed -i '' '1 s/^/\/\/@dart=2.10\n/' lib/core/assets/assets.gen.dart

I currently don't have time to submit a PR with updated functionality, but if someone else is struggling with this, they can use the workaround until a compatible version is released.

britannio commented 3 years ago

@wasabeef Any eta on generating null safe code?

wasabeef commented 3 years ago

@britannio It will be released in a few days. https://github.com/FlutterGen/flutter_gen/pull/91

wasabeef commented 3 years ago

@mark-apn @britannio

I'm sorry for the late reply.

Just now we released v3.0.2 null safety so could you try it?

flutter_gen:
  null_safety: true # Optional (default: true)

dev_dependencies:
  build_runner: 
  flutter_gen_runner: ^3.0.2 # Since v2, renamed