0

I'm trying to migrate my Flutter/Dart project to Null Safety. When I run

dart pub outdated --mode=null-safety

It appears that all my dependencies support null-safety

Showing dependencies that are currently not opted in to null-safety. [✗] indicates versions without null safety support. [✓] indicates versions opting in to null safety.

All your dependencies declare support for null-safety.

I'm using the "dart migrate" tool. When I apply changes, an error appears in my code:

The library 'package:xxx/generated/l10n.dart' is legacy, and should not be imported into a null safe library. Try migrating the imported library.dart(import_of_legacy_library_into_null_safe)

Is it really possible to migrate to null safety if translation / internationalization services are being used within Flutter projects?

David L
  • 1,134
  • 7
  • 35

1 Answers1

0

First of all make sure that even if the dependencies accept null safety you are pointing to the version of the dependency that accepts it and tries to use the latest version of it. If this does not work, try to discard packages and update those that are working with null safety, this little by little until you are allowed to update all the packages and that conflicts are not generated.

Also make sure to run the dart pub upgrade --null-safety whenever you make these changes so that no cache errors are generated.

When you execute the dart migrate command, does it allow you to enter the screen where you select the files?

If the answer is yes, then try to make all the changes, close and reopen the project and clear all the system cache, if the answer is no, maybe one of the packages you are using simply has an internal error and It is not really ready to use null safety.

If in the end none of this works, try the manual migration proposed by Flutter directly in the documentation https://dart.dev/null-safety/migration-guide

  • Thank you Andrés. All my packages are supposed to support null safety. That is the problem. I was able to run `dart migrate` without any problems. What I see so far is that the migration to null safety of medium complexity applications is not very mature yet. – David L Jul 24 '21 at 19:56