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.46k stars 146 forks source link

Optional Nullability #108

Closed cesarferreira closed 3 years ago

cesarferreira commented 3 years ago

First of all, amazing tool! Use it on the daily!

Is there a way to tell the tool not to generate dart 2.12 optional fields? Many of my projects are still on non null-sound libraries, it's quite tedious to go and delete all the ? every time the tool runs

lcdsmao commented 3 years ago

Hi @cesarferreira. Sorry for the lack of documentation. Could you try to modify your pubspec.yaml:

flutter_gen:
  null_safety: false

And then run fluttergen again?

cesarferreira commented 3 years ago

It worked! but this line at the top makes it complain that im not null sound

// @dart = 2.10

image

lcdsmao commented 3 years ago

@cesarferreira

From the error image, it seems you are in a null safety project?

It worked! but this line at the top makes it complain that im not null sound

Did you mean this?

Screen Shot 2021-05-23 at 11 39 27
cesarferreira commented 3 years ago

My min sdk is 2.7.0 and even tho the fields are not optional anymore, the line at the top that says

// @dart = 2.10

turns the whole document red, i can easily fix it by simply removing that // dart = 2.10 line but i need to go there every time, is there a way to turn it off? to not have it being pasted at the beginning of the file?

lcdsmao commented 3 years ago

@cesarferreira Thanks for the information about your project. After discussion with @wasabeef, we are deciding to not support the project with dart sdk < 2.12. The version comment @dart=2.10 and pubspec key null_safety: false are aim to support the project that cannot fully migrate to null-safety (dart >= 2.12). So if you want to use flutter_gen with your project, please try the old version like 1.31. Thanks.