Flutter 3.7: What’s New

- By Aiza Anjum

2023 has just begun with a new exciting release for Flutter i.e version 3.7. As it continues to evolve, there is no doubt that Flutter will continue to be one of the widest used cross-platform development frameworks. Let’s take a quick look at the improvements that come along with the new version:

Improved Material 3 Support:

Photo by Kevin Chisholm on Medium

Migration of certain widgets has improved the Material3 experience. Some of these widgets include Badge, Bottombar, Menus, DropdownMenu, Snackbar and TabBar. In order to use the new features you just need to turn on the useMaterial3 flag in the app’s ThemeData widget.

Menu Bars and Cascading Menus:

This release of Flutter introduces the ability to create menu bars and cascading context menus. For macOS, developers can use the PlatformMenuBar widget to create a menu bar that is rendered by macOS natively, instead of by Flutter. 

Additionally, for all platforms, developers can use the Material Design menu that provides cascading menu bars (MenuBar) or standalone cascading menus triggered by another user interface element (MenuAnchor). 

These menus are fully customizable, and the menu items can be custom widgets or use the new menu item widgets (MenuItemButton, SubmenuButton).

Impeller Preview:

A new Impeller rendering engine that is now available for preview on iOS on the stable channel. The performance of Impeller is believed to be comparable or better than the Skia renderer for most apps, and it implements all but a small number of rarely used corner cases.

iOS release validation:

The flutter build ipa command now includes a feature that checks and validates certain settings for iOS apps before submission to the App Store. 

This helps ensure that the app is ready for release by informing the developer of any changes that need to be made before submission. This new feature is a checklist of settings to update which helps developers to prepare the app for release.

DevTools Updates:

This new SDK includes several new tooling features and improvements for developers using Flutter. One of the major improvements is in the DevTools Memory debugging tool, which has undergone a complete overhaul and includes three new feature tabs: Profile, Trace, and Diff. These tabs support all the previously supported memory debugging features and add more for ease of debugging. 

The new features include the ability to analyze current memory allocation for the app by class and memory type, investigate the code paths that are allocating memory for a set of classes at runtime, and compare memory snapshots to understand memory management between two points in time.

Photo by Kevin Chisholm on Medium

Custom Context Menus:

The new context menu feature in Flutter allows developers to create custom context menus for different parts of their app, giving them more control over the user experience. This feature works by adding a new contextMenuBuilder parameter to existing widgets that already show a context menu by default, such as TextField.

Developers can return any widget they want from the contextMenuBuilder, including modifying the default platform-adaptive context menu. This feature can also be used outside of text selection, such as creating an Image widget that shows a Save button when right-clicked or long-pressed.

CupertinoListSection & CupertinoListTile widgets:

Cupertino has two new widgets, CupertinoListSection and CupertinoListTile, for showing a scrollable list of widgets in the iOS style. They are the Cupertino versions of ListView and ListTile in Material.

Scrolling Improvements:

This change will allow users to return null from the itemBuilder and indicate the end of the list, making it easier for them to work with scrolling widgets like ListView. 

Additionally, the new Scrollbars and DraggableScrollableSheet widgets will provide more control and customization options for scroll views, and the improved handling for text selection within scrolling contexts will make it easier to select text in scrolling views.

Internationalization Tools and Docs:

Internationalization support has been completely revamped.  The gen-l10n tool now supports:

  • Descriptive syntax errors.

  • Complex messages involving nested/multiple plurals, selects, and placeholders.

Text magnifier:

The magnifying glass that appears during text selection on Android and iOS now works in Flutter. This is enabled out of the box for all apps with text selection, but if you want to disable or customize it, see the magnifierConfiguration property.

Reduce animation lag on iOS devices:

Animation quality has greatly improved with the new version of Flutter, thanks to open source contributors.

Font Asset Hot Reload:

Including new fonts to the pubspec.yaml file previously required the app to be rebuilt, unlike other assets which could be hot reloaded. This problem has been solved in Flutter 3.7.

Custom Shader Support Improvements:

Custom shaders can now be hot reloaded and the new Flutter SDK contains a shader compiler that is responsible to correctly compile the listed shader in pubspec.yaml to the relevant backend-specific format for the target platform.

toImageSync:

This release adds new methods, Picture.toImageSync and Scene.toImageSync, to dart:ui. These methods are similar to the asynchronous methods, Picture.toImage, and Scene.toImage, but they synchronously return a handle to an Image. 

The rasterization for the Image takes place in the background and the image is kept as GPU resident when a GPU context is available, which makes it faster to draw compared to images produced by toImage. 

These new toImageSync APIs are useful for quickly snapping off an expensive-to-rasterize picture for reuse across multiple frames, applying multi-pass filters to a picture, and applying custom shaders.

Support discontinuation for macOS 10.11-10.13:

Flutter has announced that it will no longer support macOS versions 10.11, 10.12, and 10.13. This decision was made after further analysis revealed that removing support for these versions would have limited additional impact, and would simplify the codebase.

 This means that apps built against stable Flutter SDKs with this release and onward will no longer work on these versions, and the minimum macOS version supported by Flutter increases to 10.14 Mojave.

Consequently the OpenGL backend has been removed from both the iOS and macOS embedders which has reduced the compressed size of the Flutter engine by about 100KB.

Memory Management

This release of Flutter includes several improvements to memory management that aim to reduce lag caused by garbage collection pauses, lower CPU utilization due to allocation velocity and background GC threads, and reduce the overall memory footprint. 

One example of this is expanding the existing practice of manually deallocating native resources that back certain dart:ui Dart objects. Benchmarks of the Flutter framework migrated to this API have shown that these improvements can reduce 90%-ile frame build times by up to more than 30%, resulting in smoother animations with less jank. 

Additionally, the Flutter engine no longer registers the size of GPU images with the Dart VM, which eliminates synchronous GC work while building frames when a widget creates GPU resident images. The Flutter Engine also does a better job of dynamically updating the Dart VM with information about Flutter application state. 

Finally, for add-to-app Flutter applications, the Flutter engine now informs the Dart VM when the Flutter view is no longer displayed, this causes the Dart VM to trigger a final major GC for the Isolate associated with the view which reduces Flutter's memory footprint when no Flutter views are visible.

Previous
Previous

Building AI-Powered Apps with Flutter and ChatGPT

Next
Next

5 Innovative Ways In Which ChatGPT is Changing the Game