flutterdart-null-safety

How to add //@dart=2.9 in dart file


Now I'm working in flutter project. I need to add //@dart=2.9 in dart file. But i got run time error. Like A library can't opt out of null safety by default,when using sound null safety. How can i add it on dart file?


Solution

  • add it at the top of main.dart.

    then run $ flutter clean $ flutter pub get

    if this does not work,check this https://dart.dev/null-safety/migration-guide