Published in


Introducing Dart 3 alpha

Preview the most productive, portable, and approachable version of Dart yet. Now available for early testing and experimentation.

Dart 3 productivity enhancements

A more expressive Dart language: Records, patterns, and access controls

We’ve evolved the Dart language at a rapid pace the past few years, adding 23 new features since 2.0. In Dart 3 we expect to add two new major features, records and patterns, with the goal of making working with structured data more productive.

  • interface class: Cannot be extended.
  • base class: Disables the implicit interface, so cannot be implemented.
  • final class: Cannot extend, implement, or mix in the class (outside the current library).
  • sealed class: Same as abstract + final + the type is considered the root of a sealed type family for exhaustiveness checking. As an example, take the Shape class hierarchy above. In switch statements on the Shape type (like the calculateArea function), the analyzer will trigger errors if the switch statement does not handle all possible subtypes of the sealed type.
  • mixin class: A class which may be used as a mixin.

Productive platform integration via direct platform library interop

We’re working on expanding Dart language interoperability for calling platform libraries directly from Dart. On Apple platforms, we’re building on our work on FFI for C interoperability, which supports calling any C module that follows the C calling convention from Dart. This has so far supported languages such as C, Go, and Rust. Now, we’re adding support for Swift and Objective-C on iOS/macOS. On Android, you can call into Jetpack libraries written in Kotlin and Android libraries written in Java by leveraging FFI and Android’s Java Native Interface (JNI).

Portability advancements

Dart already supports a wide range of target platforms with our native and web compilers. On the Web, we currently compile to JavaScript. On native devices, we currently support the Intel 32-bit and 64-bit, and ARM 32-bit and 64-bit architectures. There are a number of emerging devices and standards we’re working on adding support for, to ensure Dart is ready for the devices of the future.

Dart 3 breaking changes

With the new Dart 3 capabilities covered, let’s turn to the breaking changes we’re making in the spirit of a more consistent and approachable Dart.

Dart 3 type system: 100% sound null safety

We introduced sound null safety in Dart 2.12 in 2021. In a sound typing system, you can trust the types, meaning a variable is never null when the types state that it isn’t. This raises productivity by catching issues during development rather than in production, and enables the Dart compilers to produce smaller and more optimized code. As we discussed in December, Dart is unique in introducing 100% sound null safety to an existing language.

  • 100% of the top-250 packages on pub.dev support null safety
  • 98% of the top-1000 packages on pub.dev support null safety
  • Only 14% of flutter run sessions still run without null safety

Cleanup of Dart 3 core libraries and language

As the Dart language and type system have evolved, several of the APIs in our core libraries have become redundant or suboptimal. To ensure Dart remains approachable, we’ve made a number of breaking changes to clean up unnecessary APIs. For details, see the GitHub issues, #34233 and #49529. We’ve also removed a historical syntax for default parameter values (#2357).

Preparing your code for Dart 3 stable

Generally, we believe most code that has already migrated to use null safety, using Dart 2.12 or later, will work with Dart 3. However, some small subset of packages and apps may be impacted by the breaking changes discussed above. So, to give you time to prepare for the Dart 3 stable release later this year, we have not planned any further breaking changes to the Dart language and core libraries after Dart 3 alpha.

Dart 3 tools cleanup

Leading up to Dart 3, we made a number of changes to move all our terminal developer tools into a unified dart developer tool, which made Dart a lot more approachable for new developers. We’re planning on making additional tools changes over the coming months to further cleanup. Hopefully these changes won’t be too disruptive, but some minor breakage should be expected for tooling in Dart 3 beta.

Next steps

Dart 3 alpha is available today in the Dart dev channel and in the Flutter master channel. We invite you to try it out, whether it’s to experiment with the new language features like records & patterns, try our new direct access platform interop, or test your apps & packages for Dart 3 compatibility.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Thomsen

Product Manager working on Dart and Flutter. Helping developers is my passion!