Flutter 3 is a major milestone in our official support for the entire platform. It has only been three months since its release. Today we have the official version of Flutter 3.3! We haven't slowed down our update iterations for nearly three months - we've merged 5687 pull requests for Flutter since Flutter 3 was released.
This update brings performance and other updates to the Flutter web platform, desktop platform, text processing, and more.
We will also introduce updates related to the go_router package, DevTools (developer tools) and VS Code extensions. Read on with us to learn more about them!
Framework update
Global selection
So far, Flutter's text selection interaction on the web has not lived up to expectations. Unlike Flutter apps, native web apps build each node as a tree structure. In traditional web applications you can easily use drag gestures to select nodes on the web page, which is not easy to achieve in Flutter web applications.
From today, everything has changed. We have introduced the SelectionArea
widget, whose child widgets can now be freely selected!
Just use SelectionArea
to wrap the content displayed by the route (eg Scaffold
), Flutter will take care of everything for you, and you can enjoy this powerful new feature.
For a fuller in-depth look at this awesome new feature, visit the SelectionArea API page .
Touchpad operation
Flutter 3.3 optimizes support for touchpads. Flutter not only provides richer and smoother control, but also reduces false touches in several specific situations. If you want to see examples of false touches, you can check out the Flutter Practical Tutorials page. Scroll the page to DartPad at the bottom and follow the steps below:
- Shrink the window so that scrollbars appear in the upper half
- Hover the pointer over the top half
- Scroll with the trackpad
- Before Flutter 3.3, scrolling with a trackpad would drag elements because Flutter dispatched simulated gesture events
- Starting with Flutter 3.3, scrolling with the trackpad will correctly scroll the list, because Flutter will pass "scroll" events, the cards will not recognize these events, and the list will be processed accordingly
For more information, visit the Flutter Trackpad Gestures.pdf "Flutter Trackpad Gestures")) design document, and check out the following pull requests:
- PR 89944: Support trackpad gestures in frames
- PR 31591:Touchpad gestures on iPad
- PR 34060: ChromeOS/Android trackpad gestures
- PR 31594: Trackpad gestures for Win32
- PR 31592: Trackpad gestures for Linux
- PR 31593: Trackpad gestures on Mac
Scribble function
Thanks to the awesome contributions from community member fbcouch . Flutter now supports scribble input with Apple Pencil on iPadOS . This feature is enabled by default on CupertinoTextField
, TextField
and EditableText
. Just upgrade Flutter to 3.3 to bring this new feature to your users.
text input
To optimize support for rich text editing, in this update we have added the ability to receive more refined updates from the underlying platform TextInputPlugin
. Previously TextInputClient
could only pass the new edit state, but could not subdivide the amount of change between the old and new states, TextEditingDelta
and DeltaTextInputClient
filled this part of the information difference . By accessing these deltas, you can build custom styles for the input area, which expands and contracts as you type. For more information, you can check out the rich text editor example .
Material Design 3 support
The Flutter team continues to integrate more Material Design 3 components into Flutter. This update includes medium and expanded styles for IconButton .
To track the progress of the Material Design 3 integration, you can check out Bringing Material 3 to Flutter on GitHub.
IconButton example
Chip example
Medium and Large AppBar Examples
Desktop platform
Windows
When building Windows desktop apps earlier, the version of the app could only be set in the file. Such behavior is not consistent with the behavior of setting versions on other platforms.
Versions of Windows desktop apps can now be set via pubspec.yaml
and build parameters. It helps to provide app update functionality to your users in your app when your app pushes an update.
To learn more about setting Windows desktop app version numbers, check out the documentation . Projects created before Flutter 3.3 will need to be manually adjusted to use this feature.
Packages update
go\_router publish
When your app contains complex navigation needs, it can be confusing. In order to extend Flutter's navigation API, the team released a new version of the go_router package , which makes your routing logic design on all platforms more concise.
The go\_router package is maintained by the Flutter team and makes navigation and deep links easier with a declarative and URL-based API. The latest 5.0 release, which allows apps to redirect via asynchronous code, also includes some breaking changes .
For more information, see the official documentation: Routing and Navigation .
VS Code plugin enhancements
The Flutter extension for VS Code also brings updates that add dependencies. You can add multiple dependencies at once using the Dart: Add Dependency
command followed by a comma.
You can check out the following for updates to all the Flutter plugins for VS Code since the last stable version of Flutter was released:
Flutter Developer Tools Update
DevTools has also included several updates since the last stable release of Flutter, including UX and performance improvements for data table presentations, and reduced stuttering when scrolling long lists of events ( #4175 .
Here are the announcements for each version of DevTools since Flutter 3.0:
- Flutter DevTools 2.16.0 Release Notes
- Flutter DevTools 2.15.0 Release Notes
- Flutter DevTools 2.14.0 Release Notes
performance improvements
Raster cache improvements
This update improves the performance of loading resource images and reduces the pressure of copying image data and Dart garbage collection (GC). When loading a resource image, ImageProvider
needed to copy the compressed data multiple times. First, when the image is opened, the data is copied to native heap memory and an array of structures is exposed to Dart. Then, the data is copied again when the struct array is converted to the built-in storage ui.ImmutableBuffer
.
With the introduction of the new ui.ImmutableBuffer.fromAsset . This loading process is also faster because it bypasses the overhead of the additional scheduling required by the previous method channel. In our benchmarks in particular, images loaded about 2x faster.
For more information, please check the official documentation: Add ImageProvider.loadBuffer .
frame stability
Disable iOS memory pointer compression
In the Flutter 2.10 stable release, we enabled Dart's memory pointer compression optimizations for iOS. However, Yeatse reminded us on GitHub that this optimization has consequences we didn't expect . Dart implements pointer compression by maintaining a large virtual memory for the heap. Since the total virtual memory allowed on iOS is less than other platforms, other components such as Flutter plugins can hold less virtual memory.
Although disabling pointer compression will increase the memory consumed by Dart objects, it also restores the non-Dart portion of memory available to Flutter applications, which is generally a more appropriate solution.
Apps can increase the maximum virtual memory allocation, but this is only available on newer iOS versions, and not on other versions of iOS devices supported by Flutter. We will re-evaluate when we are able to use this optimization in all locations.
API improvements
PlatformDispatcher.onError
In previous versions, you needed to manually configure a custom Zone to catch all exceptions and errors for your application. However, custom Zones don't apply to some optimizations in Dart's core library, which can slow down your app's startup time. In this update, you can catch all errors and exceptions by setting the PlatformDispatcher.onError callback instead of a custom Zone. For more information, check out the updated official documentation: Handling Errors in Flutter .
FragmentProgram Update
Fragment shaders written in GLSL and declared in pubspec.yaml
of shader:
are now automatically compiled into a format the engine can correctly recognize and automatically bound to the application's resource. With this change, developers no longer need to use third-party tools to compile shaders. In the future, the engine's FragmentProgram API may only accept tool builds from Flutter. We haven't applied this change yet, but it may be implemented in the future as planned in FragmentProgram API Improvement Support Design Document.pdf "FragmentProgram API Improvement Support Design Document").
To learn more, you can check out this Flutter shader example .
Layout decimal handling
In previous versions, the Flutter engine would precisely align compositing layers to pixels, which was used to improve Flutter's rendering performance on older iPhones (32-bit). And after we added support for desktop platforms, we noticed that this action resulted in visible jitter, because desktop platforms have lower device pixels than usual. On lower DPR devices, for example, cues can cause noticeable jitter when fading in. After determining that newer iPhone devices do not need this optimization, we have removed it from the Flutter engine to improve rendering fidelity on the desktop.
In addition, we found that removing these pixel alignments made minor rendering differences that were previously seen during the golden image test more stable.
Stop supporting 32-bit iOS
As we mentioned when we released Flutter 3.0, version 3.0 was the last version to support 32-bit iOS devices as well as iOS 9 and 10 due to reduced usage. This change will affect iPhone 4S, iPhone 5, iPhone 5C, and 2nd, 3rd, and 4th generation iPad devices. Flutter 3.3 stable and later will no longer support 32-bit iOS devices and iOS 9 \& 10. This means that apps built with Flutter 3.3 and later will no longer run on these devices.
macOS 10.11 and 10.12 support is coming to an end
We will drop support for macOS versions 10.11 and 10.12 in the upcoming Q4 2022 official release schedule. This means that the stable version of the Flutter SDK after this will not work on these versions, and the minimum supported macOS version of Flutter will be raised to 10.13 High Sierra.
Stop supporting Bitcode
The upcoming release of Xcode 14 will no longer support submitting iOS apps with Bitcode , and this version of Xcode will warn about projects that have bitcode enabled. Therefore Flutter will remove support for bitcode in future stable releases. We don't want to affect a lot of developers, so by default, Flutter will not turn on bitcode. However, if you manually turned on bitcode in your Xcode project, please turn it off as soon as possible after upgrading to Xcode 14.
You can turn it on ios/Runner.xcworkspace
and set Enable Bitcode to No in the build settings to turn it off. Hybrid development applications can turn it off in the Xcode project of the host project.
You can check out Apple's documentation to learn more about bitcode distribution.
Epilogue
The Google Flutter team really appreciates every member of the community for all the hard work that goes into making the Flutter experience even better, we look forward to building on what's been done, and we always value our most important and valuable asset - Every member of the community!
Original link : https://medium.com/flutter/whats-new-in-flutter-3-3-893c7b9af1ff
Localization : CFUG Team: @AlexV525, @chenglu, @Vadaski, @Nayuta403
Chinese link : https://flutter.cn/posts/whats-new-in-flutter-3-3
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。