Flutter 2.5 was released last week! This is an important release update and the second release of Flutter statistics in its release history. We closed 4,600 issues and consolidated 3,932 PR from 252 contributors and 216 reviewers. Looking back last year — we received 21,072 PR submissions from 1,337 contributors, of which 15,172 were consolidated. Before going into the details of this update, we would like to stress that Flutter’s primary job is always to deliver the features that developers need in high quality.
Flutter 2.5 brings some important performance and tool improvements to help developers track performance issues in their applications. At the same time, some new features have been added, This includes full screen support for Android, more Material You (also known as V3) support, updates to text editing to support switching keyboard shortcuts, viewing Widget details in the Widget Inspector, and Visual Studio Code New support for dependencies, new support for getting test coverage information from IntelliJ/Android Studio test runs, and an application template that more closely matches the real world use of Flutter applications. This release is full of exciting new updates, so let’s get started!
There are some performance improvements: the first is a PR (#25644) for pre-compiling Metal shaders from offline training runs, which reduces the rasterization time in the worst case by 2/3 (as shown in our benchmark) and the frame time at the 99th percentile by half. We’ve made continued progress in reducing iOS lag, and this is another step along that path. However, shader preheating is only one source of stalling. Prior to this release, processing asynchronous events from the network, file system, plug-in, or other ISOLATE could cause animation breaks, which was another source of lag. In this release we have improved the UI Isolate event loop scheduling strategy (#25789) so that frame processing now takes precedence over other asynchronous events and in our tests, the lag caused by this has been eliminated.
Another reason is that garbage collection (GC) pauses the UI thread to reclaim memory. Prior to this release, some image memory could only be reclaimed at a slower rate when the Dart VM performed GC. In earlier versions, it was common practice for the Flutter engine to suggest to the Dart VM that the image memory could be collected by GC, theoretically making the collection more timely. Unfortunately, in practice this results in excessive reclamation, and memory still sometimes cannot be reclaimed quickly enough to avoid low memory conditions on devices with limited memory. In the current version, unused image memory is reclaimed as quickly as possible (#26219, #82883, #84740), which greatly reduces the number of GC cycles.
For example, in one of our tests, the number of GCS for a 20-second GIF animation dropped from 400 to just 4. Less major GC means less animation lag involving images appearing and disappearing, and less CPU and power consumption.
Another performance improvement of Flutter 2.5 is to optimize the latency of communication between Dart and Objective-C/Swift on iOS and Dart and Java/Kotlin on Android. As part of tweaking the message channel, we removed unnecessary copies from the message codec, reducing latency by up to 50% across different content sizes and devices (see #25988, #26331).
For more details, see Aaron Clarke’s article improving platform Channel Performance in Flutter.
If you’re building iOS apps, we have one final performance update: In this release, Flutter apps built using Apple Silicon M1 Macs can run directly on the ARM based iOS emulator (#pull/85642). This means that there is no need to use Rosetta to convert Intel X86_64 instructions to ARM, which improves the performance of iOS application testing and avoids some subtle Rosetta issues (#74970, #79641). This is another step in Flutter’s journey to fully support Apple Silicon. Stay tuned.
Of course, without the Dart language and its runtime environment, there would be no Current Flutter, which builds on the Dart language and Runtime. Flutter 2.5 also brings Dart 2.14. The new Dart release not only brings new formatting to make cascading clearer, but also a new pub command tool that supports ignoring files, as well as new language features (including regression for the fabled unsigned right-shift operator). In addition, this release brings with it a new set of standard code specification tips shared between Dart and the Flutter project, right out of the box, which is the best part of Dart 2.14.
The Flutter Create comes out of the box with an analysis_options.yaml file that preuses the recommended flutter Lint.
Not only can you use these specifications when you create a new Dart or Flutter project, but you can add this same analysis to your existing application in just a few steps. For details on these specifications, new language features, and more, see Dart 2.14 Release.
Flutter 2.5 has several fixes and improvements to the framework. We fixed a number of issues related to Android’s full screen mode, and the Issue received hundreds of likes. The full screen options include reclining, Immersion mode, Sticky immersion mode, and edge-to-edge. This change also adds a way to listen for full-screen changes in other modes. For example, if a user changes the full screen mode of the system interface while using an app, developers can now code the app back to full screen, or do something else.
In this version, we continue to build the new Material You (v3) specifications, including suspension button size and theme update (# 86441), and a new MaterialState. ScrolledUnder state, You can see it in action with the sample code in PR (#79999).
When we talk about scrolling, another improvement is the addition of additional scroll metric notifications (#85221, #85499) that provide a scrollable area notification even if the user does not scroll. For example, the following example shows the effect of a scroll bar appearing or disappearing at the right time depending on the actual size of the ListView.
In this case, you don’t need to write any code to catch changes to the ScrollMetricNotification. Special thanks to community contributor Xu-Baolin who did a lot of work on this and came up with a good solution.
Another outstanding contribution from the community is the addition of Material banner support for ScaffoldMessenger. Added to Flutter 2.0 is ScaffoldMessenger, which provides a powerful way to display SnackBars at the bottom of the screen to provide users with notifications. With Flutter 2.5, you can now add a banner on top of that Scaffold that will remain in place until the user closes it.
The Material guide for banners states that your application can only display one banner at a time, so if your application calls showMaterialBanner multiple times, ScaffoldMessenger will hold a queue to display the next new banner when the previous banner is closed. Thanks to Calamity210 for providing a powerful addition to the Material support for Flutter.
Building on Flutter 2.0 and its new text editing capabilities, we have added features such as text selectors, the ability to intercept any overwriting keyboard events, and keyboard shortcuts to overwrite text editing (#85381). If you want CtrL-A to do something custom instead of selecting all the text, you can do it yourself. DefaultTextEditingShortcuts class contains a Flutter on each platform supported by each list of keyboard shortcuts. If you want to overwrite an association, use the existing Shortcuts Widget of Flutter to remap any shortcut key to an existing or custom intent. You can place the widget where you want to overwrite it. See the API documentation for examples.
Another plugin that has been greatly improved is the Camera plugin:
- 3795 [Camera] Android – Rework – Part 1: Basic classes that support android camera features
- 3796 [Camera] Android – Rework – Part 2: Android auto focus
- 3797 [Camera] Android – Rework – Part 3: Android Exposure related features
- 3798 [Camera] Android – Rework – Part 4: Android flash and zoom
- 3799 [Camera] Android – Rework – Part 5: Android FPS range, resolution, and sensor orientation
- 4039 [Camera] Android – Rework – Part 6: Android Exposure and focus functions
- 4052 [Camera] Android – Rework – Part 7: Android noise reduction
- 4054 [Camera] Android – Rework – Part 8: Support module for final implementation
- 4010 [Camera] Does not trigger device orientation when flat on iOS
- 4158 [Camera] Fixed setting focus and exposure point coordinate rotation on iOS
- 4197 [Camera] Fixed issue where camera preview does not always rebuild when the device orientation changes
- 3992 [Camera] prevents crashes when setting unsupported FocusMode
- 4151 [camera] introduces the CamerA_web package
A lot of work has also been done on the Image_Picker plug-in, which focuses on the end-to-end camera experience.
- [image_picker] Image collector repair camera equipment
- 3956 [image_picker] Changes the storage location captured by the camera to internal cache in Android to meet the new Google Play storage requirements
- 4001 [image_picker] removes redundant camera permission requests
- 4019 [image_picker] Fixes rotation issues when the camera is the source
These efforts improve the functionality and robustness of Android’s camera and image_picker plug-ins. In addition, you may notice that the Web functionality of the Camera plug-in is in the preview phase (#4151). This preview provides basic support for viewing camera previews, taking photos, using flash and zoom controls, all of which can be done on the Web. It is not currently a recognized federated plug-in, so in your configuration, you need to make it clear that the plug-in can only be added to Web applications.
The initial Android camera refactoring was contributed by Acoutts. Camera and Image_Picker’s work was done by Baseflow, a consulting firm specializing in Flutter, known for its package on pub.dev. Camera_ Web’s work was primarily done by Very Good Ventures, a US-BASED Flutter consulting firm. Thank you so much for your contribution to the Flutter community!
Another valuable community contribution was made by the Fluttercommunity.dev organization, whose representative work is the Plus family of plug-ins. With the release of a new version of Flutter, plug-ins previously maintained by the Flutter official team are now “handed over” to the Fluttercommunity.dev organization, with a similar message below each plugin:
In addition, we have removed the Flutter Favorite flag from these plug-ins because they are no longer actively maintained. If you haven’t already migrated to the Plus family of plug-ins, we suggest you follow the chart below for a comparison migration.
Flutter 2.5 has a number of improvements to Flutter DevTools. The first is the addition of support for engine updates in DevTools (#26205, #26233, #26237, #26970, #27074, #26617). One set of updates enabled Flutter to better associate tracking events with specific frames, which helped developers determine why a frame might be over budget. You can see this in the DevTools framework diagram, which has been refactored to support live presentation; When your application is rendering, their data will be filled into the image. Select a build frame from this diagram to jump to the timeline event for that frame.
The Flutter engine can now also recognize shader compilation events in the timeline. Flutter DevTools uses these events to help you diagnose shader compilation defects in your application.
With this new feature, DevTools can detect build frames you’ve lost due to shader compilation to help you fix the problem. If you want to run the flutter run command as if you were running the app for the first time, add the –purge-persistent-cache flag to the flutter run command. This clears the cache of the shader to ensure that you recreate what the user sees when they “first run” or “re-open” the app (iOS). This feature is still under development, so please send us any problems or suggestions for improvements you find to help discover and improve the shader compilation tool.
In addition, when you track CPU performance issues in your application, you may already be drowning in profiling data from native code in Dart and Flutter libraries or engines. If you want to turn off this data to focus on your own code, you can use the new CPU Profiler feature (#3236) that allows you to hide Profiler information from any of these sources.
For the categories you didn’t filter out, they are now color-classified (#3310, #3324) so you can see the corresponding parts of the CPU flame map content very clearly.
Performance may not be the only thing you want to debug. The new version of DevTools comes with an update to Widget Inspector, which allows you to evaluate objects, view properties, Widget status, and more when you hover over a Widget.
And when you select a widget, it automatically pops up in the new Widget Inspector Console, where you can freely explore the widget’s properties.
In addition to new features, the Widget Inspector also gets a facelift. In order to make DevTools the best tool for understanding and debugging Flutter applications, we worked with Codemate, a Finnish creative technology agency, to implement some updates.
As shown above, you can see the following changes:
- Better communicate the debug toggle buttons — they have new ICONS, task-oriented labels, and rich tooltips that describe what they do and when to use them. Each tooltip is further linked to detailed documentation of the feature.
- Easier to find and locate Widgets of interest — Widgets frequently used in the Flutter framework are now resident as ICONS in the Widget tree view to the left of Inspector. They have been classified according to their category using color. For example, the layout widget is blue and the content widget is green. In addition, each text widget now displays a preview of its content.
- More consistent Layout Explorer and Widget tree color scheme – It is easier to identify the same widget from the Layout Explorer and Widget tree. For example, the “Column” widget shown above has a blue background in the Layout Explorer and a blue icon in the Widget tree view.
We’d love to hear any questions and suggestions you have about these updates to make sure DevTools runs efficiently. These highlights are just the beginning. For all the new DevTools content in Flutter, please refer to the following release notes:
- Description of Flutter DevTools version 2.3.2
- Description of Flutter DevTools version 2.4.0
- Description of Flutter DevTools version 2.6.0
The IntelliJ/Android Studio plugin for Flutter also has some improvements in this release, starting with the ability to run integration tests (#5459). Integration tests are full application tests that run on the device, in the Integration_test directory, and use the same testWidgets() functionality as widget unit tests.
To add integration tests to your project, follow the instructions on the Flutter documentation website. To connect tests to IntelliJ or Android Studio, add a run configuration, launch integration tests, and connect a device for testing. Run configuration allows you to set breakpoints, steps, and so on while running tests.
Additionally, Flutter’s latest IntelliJ/Android Studio family of plug-ins allows you to view coverage information for both unit test and integration test runs. You can access this information via the toolbar button next to the “Debug” button:
Coverage information will be displayed as red and green rectangles in the gap to the left of the edit window. In this example, lines 9-13 are covered by tests, but lines 3 and 4 are not.
The latest version also includes a new ability to preview ICONS used in packages from pub.dev, which are built around TrueType font files (#5504, #5595, #5677, #5704), Just like the Material and Cupertino ICONS support preview.
To enable icon preview, you need to tell the plug-in which package you are using. There is a new text field on the plug-in’s Settings/preferences page.
Note that this works for ICONS defined as static constants in a class, as shown in the sample code in the screen capture. It does not work on expressions such as lineicons.addressbook () or lineicons.values [‘code’]. If you are the author of an icon package that is not suitable for this feature, please create an Issue for feedback.
For more information about updates to Flutter’s IntelliJ/Android Studio plugin, see the following release notes:
- The Flutter IntelliJ Plugin M57 is released
- Release of the Flutter IntelliJ Plugin M58
- Release of the Flutter IntelliJ Plugin M59
- The Flutter IntelliJ Plugin M60 is released
The Visual Studio Code plugin for Flutter has also been improved in this release, starting with two new commands “Dart: Add Dependency” and “Dart: Add Dev Dependency” (#3306, #3474).
These commands provide functionality similar to the Pubspec Assist plug-in for Jeroen Meijer that has been available for some time. Out of the box, these new commands provide a type-filtered list of packages retrieved periodically from pub.dev.
You may also be interested in the “Fix All” command (#3445, #3469), which is available to the Dart file and fixes All the same problems as Dart Fix in one step.
You can also set it to run on save time in VS Code by adding source.fixAll to editor.codeActionsOnSave.
Or if you want to try the preview function, you can enable the dart. PreviewVsCodeTestRunner Settings, see the dart and Flutter test by new Visual Studio Code running test runner.
The Visual Studio Code test runner looks a little different from the current Dart and Flutter test runners in that it displays the results in a different session. The Visual Studio Code Test runner also added a new Gutter icon on the left side of the edit screen to show the test’s execution result status, which can be clicked to run the test (or right-click on the context menu).
In future releases, the existing Dart and Flutter test runners will be removed in favor of the new Visual Studio Code test runners.
This is just the tip of the iceberg of new features and fixes for Visual Studio Code plug-ins. For details, please refer to the following release notes:
- V3.26 VS Code Test Runner integration, Flutter creation Settings…
- V3.25 Additional dependency management improvements, fix all at file/save time…
- V3.24 dependency tree improvements, easier launch configuration, editor improvements
- V3.23 Configuration file mode improvements, improved dependency tree, improved LSP
In previous versions of Flutter, you might have been plagued by exceptions that you didn’t want to handle. You might have expected them to trigger the debugger and find out where they came from, only to find that the Flutter framework didn’t let the exception through to trigger the “unhandled exception” handler in the debugger. In this release, the debugger can now correctly interrupt unhandled exceptions that were previously just caught by the framework (#17007). This improves the debugging experience, as the debugger can now point directly to exceptions thrown in the code, rather than to a random location deep in the framework. A new feature associated with this is the ability to determine whether FutureBuilder should rethrow or hide errors (#84308). This should give you more exceptions to help you track down problems in the Flutter application.
The Counter application template has been available since the creation of Flutter and has many advantages: it demonstrates many features of the Dart language, demonstrates several key Flutter concepts, and is small enough to fit into a single file even with many explanatory comments. However, it does not provide a particularly good demonstration of the practical use of Flutter applications. In this version, you can create a new template (#83530) by using the following command.
$ flutter create -t skeleton my_app
The new Skeleton template generates a two-page list view of the Flutter application (with detailed view) and follows community best practices. It was developed through extensive internal and external reviews to provide a better foundation for building an application that achieves product-grade quality. It supports the following features:
- Use ChangeNotifier to coordinate multiple widgets
- By default, localization is generated using ARB files.
- Include a sample image and create 1x, 2X, and 3X folders for image resources.
- Use a “feature first” folder organization
- Support shared_preference
- Support light and dark theme design
- Supports navigation between multiple pages
As time goes on and Flutter best practices evolve, hopefully this new template will evolve as well.
If you’re developing a plugin rather than an app, you might be interested in Pigeon version 1.0. Pigeon is a code generation tool for generating type-safe interaction code between A Flutter and its host platform. You can define the API description of the plug-in and generate template code for Dart and Java/Objective-C/Kotlin/Swift.
Pigeon has already been used in some of the Flutter team’s plug-ins. This release provides more useful error messages, adds support for generics, primitive data types as parameter and return types, and multiple parameters, which will be used more widely in the future. If you want to use Pigeon in your own plugin or add-on app project, check out the Pigeon Plugin page for more information.
Here are the damaging changes to Flutter 2.5:
- Default device drag and scroll
- Deprecated apis have been removed since v2.2
- Package introduction: Flutter_lints
- ThemeData’s accent property is deprecated
- Gesture recognizer cleanup
- Will AnimationSheetBuilder. Replace to collate the display
- Render platform views in the Web using HTML slots
- Migrate LogicalKeySet to SingleActivator
For a complete list of damaging changes since version 1.17, see the Flutter documentation website.
As we continued to update the Flutter Fix (available in the IDE and via the Dart Fix command), we applied a total of 157 rules to migrate code that was affected by destructive changes and any deprecations. As always, we are grateful to the community for providing testing that helped us identify these disruptive changes. For more information, please refer to Flutter Destructive Modification Policy.
In addition, with the release of Flutter 2.5, we will drop support for iOS 8, as announced in September 2020. Ditching support for iOS 8, which had less than 1% of the market, allowed the Flutter team to focus on a wider range of new platforms. Deprecation means that Flutter may be available on these platforms, but we will not be testing new versions of Flutter or plug-ins on these platforms. You can see a list of the platforms currently supported by Flutter on the Flutter documentation website.
Finally, as always, thanks to the Flutter community organizations and community members around the world who made this possible. Every single one of the hundreds of developers who contributed and reviewed over 1,000 PR in this update made this possible. Let’s work together to transform the app development process for developers everywhere, so that developers can deliver more apps, develop faster, and deploy to more platforms you care about from a single code base.
Stay tuned for more updates from the Flutter team. The year isn’t over yet!
Thanks to the members of the flutter.cn community (@alexv525, @Vadaski, @Meandni) and Yuan and Lynn for their contribution to this article.