Error: No named parameter with the name 'nullOk'. after updating to FLutter 2.0
This is due to the version of Flutter you're using (stable channel, Flutter 2.0.3) is null-safety enabled. These are the APIs that were subject to change & so you need to use this migration guide to modify your code to use the new form of the APIs with null safety.
Method 1:
Check if you're using any of the aforementioned API dependencies & use .maybeOf(context)
instead of .of(context, nullOk: true);
In your posted code,change your Localizations.localeOf(context, nullOk: true);
to Localizations.maybeLocaleOf(context);
Method 2:
Find the dependency that caused the problem & update it to null safety, for example, if you're using flutter_svg: ^0.19.0
you'll encounter the same error, so either update it to flutter_svg: ^0.20.0-nullsafety.3
or in case you can't migrate to null safety yet, use this version flutter_svg: ^0.19.3
Method 3:
Alternatively, if you can also downgrade your Flutter version which doesn't provide null safety. It should also fix the error but needs the downgrading. To downgrade to v1.22.6 run the following command:
flutter downgrade v1.22.6
After each/any method, run the following commands:
flutter cleanflutter pub getflutter run