I'm using flutter retrofit package (https://pub.dev/packages/retrofit) but they doesn't have null safety version yet. When I run build and the generated code doesn't have the null check. How can't i solve this without manual add "// @dart=2.9" to each generated file?
How to handle generated code with Flutter null safety?
809 views Asked by Kyo Huu At
2
There are 2 answers
0
On
As docs mention:
Wait for the packages that you depend on to migrate.
Run this command to check if all of your packages are ready to migrate. Although most of the packages are now null-safe.
dart pub outdated --mode=null-safety
If you're not ready yet, set the lower Dart SDK constraint to 2.9
for example, in your pubspec.yaml
file:
environment:
sdk: '>=2.9.0 <3.0.0'
If code you're including isn't null-safe yet, you need to disable null-safety for your whole project, and inform the package author that you're waiting. :)