[dart-announce] Breaking change 49530: Discontinue non-null-safe mode

Skip to first unread message

'Michael Thomsen' via Dart Announcements

Sep 8, 2022, 7:28:13 AMSep 8
to Dart Announcements
Tracking & feedback issue: https://github.com/dart-lang/sdk/issues/49530


In the Dart 2.12 release, Dart introduced sound null safety. When this was introduced we used an opt-in model: Only code that was opting into language version 2.12 or later was run with null safety. Dart developers could migrate their code in a stepwise fashion.

We are now planning a Dart 3 release -- tentatively slated for release by mid-2023 -- where we plan on only supporting Dart code that uses full sound null safety. This means that the null safety legacy mode will be discontinued, and that all code must run with full sound null safety.


The reasons for making this change are:

  • Supporting both unsound and sound null safety adds overhead and complexity. Dart developers need to learn and understand both modes. Whenever reading a piece of Dart code, you need to check the language version to see if types are non-null by default (2.12 and later) or nullable by default (versions below 2.12)

  • Having to support both modes in our compilers and runtimes slows us down in terms of evolving the Dart SDK to support new features.

  • Our statistics on both packages on pub.dev and the null safety mode in which Flutter apps run, show that the ecosystem has largely already migrated to full sound null safety, and thus is ready to turn off unsound null safety/legacy mode.

Projects with a lower SDK constraint below 2.12 (e.g. sdk: ">=2.7.0"), or code containing any language version markers (e.g. // dart=2.9) will no longer work.

Planned to land in a Dart 3 release, tentatively slated for release by mid-2023.

We expect to offer an alpha/preview release several months prior to the stable release, which can be used for compatibility testing.

All code will have to be migrated to use full, sound null safety.

Packages already migrated to null safety with Dart 2.12 or later will is most cases continue to work; see details in the tracking issue.

For more ways to connect visit https://dart.dev/community
Reply all
Reply to author
0 new messages