Dart 2.13 has just been released! We have many great features in this release, including expanded support for building command-line apps, a new structured concurrency API, and improvements to the core language and VM. This article will give you the most up-to-date information on the null security feature introduced in version 2.12 and the new features of version 2.13, and the latest news on Docker and Google Cloud support for Dart backends.
What’s new in Dart 2.13: Features and Performance Improvements
Here is the list of the latest features introduced in Dart 2.13:
- Migrating Code To Null safety
- Type Aliases
- FFI Changes
- Performance Improvements
- Support For Docker
- Cloud Support For Dark Backend
Let’s understand these features in detail.
1) Migrate Code to Null Safety
Null safety is introduced in Dart 2.13, significant productivity and desired feature that assists developers in avoiding null mistakes by making variables non-nullable by default. Variables with null safety cannot hold null values unless you explicitly allow them. According to the official blog post, 93 % of the top-500 popular packages on pub.dev support null safety. The Dart community suggests converting existing programs to make use of null safety features. The community has also created a null-safety migration guide to help developers quickly transition their work to null safety. Moreover, null safety is enabled in the Dart create and flutter create templates, so null safety will default in new apps and packages.
2) Dart 2.13 FFI Changes
FFI stands for Foreign Function Interface. Flutter mobile uses the Dart FFI library to invoke native C APIs and bind to native code. Dart FFI has been updated to version 2.13. FFI now supports structs with inline arrays. Secondly, it understands packed structures. When structures are specified, the compiler has the ability to add paddings. Padding is space without real data in structure memory allocation, and it makes addresses of member variables easily available to the CPU. You can define padding using @Packed(alignment>) in this version. Paddings are often not inserted when a structure is packed. Some paddings have been removed to reduce overall memory use in platform-specific ways.
3) Type Aliases
It’s a new function introduced in version 2.13. It is also known as Typedef. Although function typedef has been available in earlier dart versions, this version introduces non-function type aliases (typedef). When you use type aliases, you’re not creating a new type; rather, you’re establishing aliases for an existing type. You can reduce the names of complicated types by using type aliases. This improves code readability, maintainability, and clarity. It’s also useful if you want to switch up your type. Instead of changing the type many times throughout the code, you have to do it once.
4) Performance Improvement
Dart had been developing since its beginning in 2013. The community and contributors strive to improve it by introducing new features and making substantial modifications to the code. They have considered reducing the application and memory footprint of the Dart code in this version. They redesigned the Dart native runtime to optimize internal structures that reflect the AOT-compiled Dart program’s metadata. This structure takes up a significant amount of memory. Dart 2.13 introduces a number of improvements that use the –split-debug-info switch to remove overhead and reduce the space consumed by program information.
5) Support for Docker
Dart’s official image is now available. Although Dart has previously offered Docker images, these new Dart images are tested and validated by Docker to adhere to best practices. They also enable AOT compilation, which can significantly decrease the size of the build container and accelerate deployment in a container environment like Cloud Run.
6) Cloud Support for Backend
Flutter uses the Dart programming language to create cross-platform and native-like user interfaces. Dart servers can leverage a variety of Google cloud products due to pre-packaged Docker images for Dart. The Dart community is collaborating with the Google Cloud team to create the Function Framework. The Functions Framework is a FaaS (Function as a Service) framework for writing Dart functions that may deploy instead of server applications. It is a community-supported project that allows you to write functions that deal with HTTP requests and CloudEvents. Developers may use Cloud Run, Google’s managed serverless platform, to run server-side Dart code. It is used with Dart’s Docker Images to provide customizable container support.
Developers may utilize Cloud Run’s serverless platform to build highly scalable, high-performance APIs and event-driven apps. This streamlines the deployment experience and frees developers from infrastructure management.
The Final Takeaway
So it’s all about the new Dart 12.3. If you’ve been waiting for the right time to migrate your dependencies to a clean, safe environment, you might want to use dart pub outdated to double-check. At the time, 93% of the top 500 most popular packages had been migrated. It is an excellent time for you to relocate. Try out the new and enhanced features described in this article, and let us know what you feel after using them.