Null values will not be permitted in areas where they aren’t expected to appear when the third major Dart programming language update will be released in mid-2023.
Dart, an object-oriented and garbage-collected C language that once aspired at JavaScript replacement, supports sound null safety. This is a way to prevent errors accessing null variables. It maintained two modes: null safety and partial null safety.
“Our next release Dart 3, completes the journey towards a full sound, null-safe language,” Michael Thomsen (product manager for Dart and Flutter) stated in a blog post. “As the final step in that journey, we are removing many historical Dart language and SDK artifacts. This includes support for running without proper nuclear safety.”
Thomsen explained that not all implementations of null safety are so secure. TypeScript is an example. You can assign a null variable a null value. C# also has exceptions to its null checking. Kotlin has its exceptions.
However, there is a price. Sound null security will be the only choice, so pubspec files – Dart package metadata – with an SDK constraint for less than 2.12 won’t resolve in Dart. Thomsen says that sound null safety is supported by about 85 percent of Flutter code written in Dart. All remaining 15% of apps and packages written in Dart are encouraged to modify their code before Dart 3 arrives.
German automaker BMW revised the null safety code for its MyBMW app. It was built using Dart framework Flutter. Christian Schmid, BMW AG’s head of mobile app development, stated that while the null-safety migration was challenging for a large-scale codebase such as the MyBMW App, Google’s tools were invaluable. We are happy to have a more error-prone codebase now that the migration is complete.
According to Stack Overflow’s 2022 Developer Survey, Dart is currently 16th in popularity for programming languages. Nearly 72,000 respondents said Dart was used by 6.54 percent, Rust (14th) by 9.32 percent, Go (13th) by 11.15 percent, Kotlin (15th) by 9.16 percent, and Apple’s Swift programming language (19th) by 4,91 percent. JavaScript (1st) was the most popular language used by survey respondents, with 65.36%.
The next major milestone in Dart 3 will likely be the support for compiling Dart codes into WebAssembly (Wasm). This will allow Flutter Web applications to run natively in browsers after the release of Dart 3. This effort will require cooperation from the W3C and browser vendors to add support for garbage-collected languages (like Dart) to Wasm via the WasmGC extension.
Related Stories: