|Dart 3 Will Be Fully Sound And Null Safe
|Written by Kay Ewbank
|Monday, 19 December 2022
The next version of Dart will be "a fully sound null safe language" according to the Dart development team, and in order to achieve this several historical Dart language and SDK artifacts are being removed, including removing support for running without sound null safety.
Null safety was introduced in Dart 2.12 to help developers avoid null errors, a class of bugs that are often hard to spot. For Dart 3 the developers are pushing this even further. Until now the null safety support in the Dart language made variables non-nullable by default, and only allowing nulls when explicitly declared.
Version 3 of Dart will only support sound null safety, which guarantees that a non-nullable variable never contains a null value. Some pubspec files will stop resolving in Dart 3 and later, and any source code containing language markers will fail when you set the constraint to less than 2.12 (e.g. // @dart=2.9).
The Dart team says they believe that around 85% of all executions of flutter run use sound null safety at this time. Those developers who have apps or packages in the remaining 15% need to migrate before Dart 3 ships (expected around mid-2023). To help you achieve this the team has put together the following video:
Alongside the null safety change, some other "historical artifacts in the Dart language and core library APIs" are being removed, including the discontinued core library APIs, removing a historical syntax for default parameter values, and requiring tear-offs to be explicit.
There are some additions to Dart 3, including improved interoperability with other programming languages and new language features, but details of most of these are still under wraps.
or email your comment to: firstname.lastname@example.org