What’s new in Flutter 3.22
Table of Contents
WebAssembly, graphics rendering enhancements, and expanded AI integration options.
During Google I/O 2024 , a stable version of Flutter – 3.22 and Dart – 3.4 has been released. Much-awaited changes to web compiling and rendering have been implemented.
We’re excited to announce the arrival of Flutter 3.22, the latest stable release of Google’s popular framework for building beautiful cross-platform apps. This release brings a wave of improvements across the board, from performance enhancements under the hood to exciting new features for developers. Whether you’re building mobile applications or targeting the web, Flutter 3.22 offers something valuable for everyone.
This article serves as a comprehensive guide for developers eager to dive into the details of Flutter 3.22. We’ll explore the key highlights of this release, including the much-anticipated stable release of WebAssembly support, advancements in the Impeller engine, and platform-specific improvements for both Android and iOS. Additionally, we’ll cover any noteworthy changes within the Flutter ecosystem and provide resources to help you navigate breaking changes and deprecations.
Web Assembly (Wasm)
One of the most significant advancements in Flutter 3.22 is the stable release of WebAssembly (Wasm) support. WebAssembly is a new instruction format designed to run code efficiently within web browsers. Traditionally, Flutter web apps relied on JavaScript for execution, which can sometimes lead to performance bottlenecks, especially for complex UI elements or animations.
With Wasm support, Flutter apps can now be compiled into a more performant binary format that runs directly on the web browser’s engine. This translates to smoother animations, faster rendering times, and an overall more responsive user experience for web applications built with Flutter.
Here’s a simplified breakdown of how to leverage Wasm in your Flutter projects:
- Upgrade to Flutter 3.22 or later. This ensures you have access to the stable Wasm toolchain.
- Build your Flutter web app with the –web-renderer=wasm flag. This instructs the Flutter build process to target Wasm instead of JavaScript.
- Serve the generated Wasm binary and accompanying assets through an HTTP server. This allows the web browser to load and execute your Flutter app.
It’s important to note that Wasm support in Flutter is still under active development. While it offers significant performance improvements, there might be some limitations or edge cases to consider. Refer to the official Flutter documentation for the latest information on Wasm support and any known limitations.
Engine
The heart of any Flutter application is the engine, which is responsible for rendering UI elements and handling platform interactions. Flutter 3.22 brings exciting advancements to the engine, particularly with the Impeller rendering engine.
Impeller Vulkan Backend on Android
A major highlight of this release is the completion of the Vulkan backend for Impeller on Android. Vulkan is a powerful graphics API that offers significant performance improvements over traditional rendering methods. By leveraging Vulkan, Flutter apps on Android can now achieve smoother graphics rendering, leading to a more visually appealing and responsive user experience. This is particularly beneficial for applications that rely heavily on animations, complex UI elements, or 3D graphics.
Ongoing Optimizations and Experimental API
The Flutter team continues to refine the Impeller engine with ongoing optimizations for specific areas like blur effects and complex path rendering. These optimizations aim to improve the efficiency of rendering these visual elements, leading to smoother performance and potentially lower battery consumption for mobile devices.
Additionally, Flutter 3.22 introduces a new experimental API for testing with Impeller. This API allows developers to write unit tests that target the Impeller engine specifically. This can be helpful for ensuring consistent rendering behavior across different platforms and devices.
Important Note: While the Vulkan backend on Android represents a significant step forward, it’s crucial to remember that Impeller is still under development. The iOS migration to Impeller is ongoing, and further expansion of Android support is planned for future releases. Refer to the official Flutter documentation for the latest information on Impeller and its capabilities.
Framework
Beyond the engine improvements, Flutter 3.22 introduces some valuable new features within the core framework itself. These features aim to enhance developer productivity and streamline the app development process.
Flutter 3.22 introduces a new feature for conditionally bundling assets based on flavor configurations. This functionality allows developers to specify which assets are included in the final app bundle based on the build flavor (e.g., dev, prod, staging).
Here’s a potential use case: Imagine you have a development environment with additional logging assets for debugging purposes. With conditional asset bundling, you can exclude these logging assets from the production build, resulting in a smaller and more optimized app for your users.
To leverage this feature, you can utilize the new usesAssets property within your flutter block in the pubspec.yaml file. This property allows you to define a list of asset patterns that should only be included for specific build flavors.
Transforming Assets at Build Time
Another exciting addition to the framework is a new API for transforming assets at build time. This functionality allows you to manipulate assets during the build process, opening doors for various use cases.
For instance, you could leverage this API to:
- Compress images before they are included in the app bundle, reducing the overall app size.
- Generate code based on asset content, streamlining specific development tasks.
The specific implementation of asset transformation will depend on your needs. However, Flutter 3.22 provides the building blocks for developers to create custom build-time transformations to optimize their workflows.
Android
Since we’ve already discussed the significant impact of the Vulkan backend on Android through the Impeller engine section, let’s explore some additional Android-specific changes in Flutter 3.22:
Deep Linking Enhancements
While deep linking functionality has always been available in Flutter, developers now benefit from a new deep link validator tool within DevTools. This tool specifically supports checking web configuration for Android apps, helping you identify and troubleshoot any errors in your deep link setup. This can significantly streamline the process of ensuring seamless deep linking experiences within your Flutter app on Android.
Predictive Back Gesture
Flutter 3.22 introduces support for the predictive back gesture on Android. This gesture allows the system to anticipate the user’s intent to perform back navigation by detecting swipes near the edge of the screen. By integrating this functionality, you can enhance the user experience on Android devices by providing a more responsive and intuitive back navigation experience.
Gradle Kotlin DSL Support
For developers familiar with Kotlin, Flutter 3.22 brings welcome news. This release now offers support for using Gradle Kotlin DSL within Gradle build scripts on Android. This allows you to leverage the benefits of Kotlin for a more concise and expressive way to configure your Android build process within Flutter projects.
End of Support for KitKat
It’s important to note that with Flutter 3.22, Google is officially ending support for the Android KitKat (Android 4.4) operating system. This aligns with Google’s broader strategy to focus on supporting more recent Android versions that offer improved security features and performance optimizations. If your app targets KitKat devices, you’ll need to consider migrating to a newer minimum-supported Android version to continue receiving updates and bug fixes from the Flutter team.
iOS
Platform views are a powerful mechanism that allows you to embed native iOS UI elements within your Flutter app. However, performance considerations have historically been a concern when using platform views, especially within scrolling views like list views.
Thankfully, Flutter 3.22 brings significant advancements in platform view performance on iOS. Here’s a breakdown of some key improvements:
- Reduced GPU Usage: The update boasts a notable 50% reduction in GPU usage when using platform views. This translates to lower power consumption and potentially smoother scrolling experiences for your users.
- Improved Frame Rendering: Frame rendering times have also seen a significant improvement, with an average reduction of 1.66 milliseconds (33%). This translates to a more responsive and visually fluid user experience, especially when dealing with complex layouts that involve platform views.
These performance optimizations directly address a pain point for many Flutter developers working with iOS. By leveraging the improvements in Flutter 3.22, you can now create more performant and visually appealing apps that seamlessly integrate native iOS UI elements within your Flutter codebase.
Ecosystem
The Flutter ecosystem continues to thrive with new tools, plugins, and updates that enhance the developer experience. Here are some noteworthy additions in Flutter 3.22:
Vertex AI for Firebase Dart SDK Preview Release
This exciting preview release brings the power of Vertex AI, Google’s machine learning platform, directly to your Flutter apps. With the Vertex AI for Firebase Dart SDK, you can leverage pre-trained models and custom models hosted on Vertex AI to add intelligent features to your apps. This opens doors for various use cases, such as image recognition, text classification, and sentiment analysis, all directly within your Flutter codebase.
DevTools Updates
Flutter DevTools, the suite of debugging and profiling tools for Flutter developers, receives updates in this release. While the specific details will be available in the official release notes, you can expect enhancements to existing functionalities and potentially new features to streamline your development workflow.
Google Mobile Ads SDK for Flutter
Developers building monetization strategies into their Flutter apps will be happy to know about the ongoing improvements to the Google Mobile Ads SDK for Flutter. While details are subject to the official SDK documentation, you can expect continued efforts to ensure seamless integration of ad formats and improved performance within your Flutter applications.
Breaking Changes and Deprecations
Before diving headfirst into development with Flutter 3.22, it’s crucial to be aware of any breaking changes or deprecations that might impact your existing codebase.
ColorScheme.fromSeed
The ColorScheme.fromSeed constructor has been deprecated in favor of a new API for creating color schemes. The recommended approach now involves using named constructors provided by the ColorScheme class. Refer to the official Flutter documentation for the latest guidance on creating color schemes.
Removal of v1 Android Embedding
Version 1 of the Android embedding has been removed entirely in Flutter 3.22. Version 2 has been the default for many releases now, and the Flutter tooling already prevented building v1 apps unless specifically overridden. If you have any legacy projects still using v1 embedding, you’ll need to migrate them to v2 to ensure compatibility with Flutter 3.22.
Deprecations Removed in 3.22
In addition to the removal of v1 Android embedding, Flutter 3.22 also removes several previously deprecated APIs. These APIs were marked for deprecation in earlier releases and are now officially removed from the codebase. A complete list of these removed APIs and migration guides can be found in the official Flutter release notes.
Staying Informed: To ensure you’re always up-to-date on breaking changes and deprecations in future Flutter releases, consider subscribing to the Flutter announce and Dart announce mailing lists. Additionally, the dart fix command-line tool can help automate some breaking change migrations within your codebase.
Conclusion
Flutter 3.22 marks a significant step forward for the framework, delivering a range of performance enhancements, new features, and ecosystem improvements. From the stable release of WebAssembly support to advancements in the Impeller engine and platform-specific optimizations, this release empowers developers to build even more performant and visually appealing cross-platform apps.
Before upgrading, be sure to review the breaking changes and deprecations to ensure a smooth transition. We encourage you to explore the new features in Flutter 3.22 and leverage its potential to take your Flutter development skills to the next level. Stay tuned for future releases that promise even more exciting advancements in the world of Flutter!