Flutter 3.16 is released, come and see what updates are there

Reference original text: https://medium.com/flutter/whats-new-in-flutter-3-16-dba6cb1015d1

Flutter has released a new quarterly update again, along with Dart 3.2. Starting from 3.16 this time, Material 3 will become the new default theme. In addition, Android has also received preview support for Impeller. There's also a major update to the Flutter Casual Games Toolkit .

Best of all, Android support is coming for Impeller.

Framework

Material default

Now, starting from 3.16, in MaterialApp will be true by default. If you still want to use M2, you can use < a i=3> to use the theme effects of M2, However, Material 2 related things will be deprecated and deleted in the future. useMaterial3useMaterial3: false

In addition, some Widgets on M3 are not fully compatible with M2, so after updating to 3.16, you may need to manually migrate and adapt some UIs, such asNavigationBarUI effect of .

More migration issues can be found at: https://github.com/flutter/flutter/issues/91605. In addition, you can compare the different effects of the two themes through https://flutter.github.io/samples/material_3.html.

The theme under M3 is mainly determined by ThemeData.colorScheme and ThemeData.textTheme. The first choice for creating Material 3 color matching is to use ColorScheme.fromSeed(). In addition, you can also use ColorScheme.fromImageProvider to obtain color scheme support from the image.

The work is done, so we recommend everyone to adapt as soon as possible.

In addition, improvements to M3 motion include the addition of Easing and Durations classes, and Material 2 curves are now renamed to include "legacy" warning that it will eventually be deprecated and removed. ( #129942 )

To put it simply, motion.dart has been added to replace the old curves.dart#L26 .

Add additional options to edit menu

On iOS, users can now select text and launch a share menu that offers a variety of standard services, with find, search, and share options added in version 3.16.

Add TextScaler

To support Android 14's [non-linear font scaling feature](https://blog.google/products/android/android-14/#:~:text=Also%2C you can improve readability,rate than smaller font size.) to aid the visually impaired, the new TextScaler class replaces the Text.textScaleFactor attribute. ( #128522 )

SelectionArea Update

SelectionArea now supports mouse click, double click, and long press native gestures related to touch devices. These new gestures are available by default via SelectionArea and SelectableRegion Come support:

  • Click: Set a collapsed selection at the clicked location
  • Double click: select the word at the clicked position
  • Double click + drag: Expand selection in word block

  • Long press + drag: Expand the selection in the word block.

Menu items that operate on the focused Widget

3.16 Started adding the ability to clear focus changes when using menu items: FocusManager's applyFocusChangesIfNeeded now supports restoring menu focus when the user clicks a menu item , focus will return to the item that had focus before the menu was opened. ( #130536 )

Menu item shortcuts for iOS and macOS are automatically reordered

Flutter apps on Mac can now sort shortcut modifiers in menus to follow Apple Human Interface Guidelines. ( #129309 )

MatrixTransition animation

New MatrixTransition Allows matrix transformations when creating animated transitions, providing the child widget's matrix transformation based on the current animation values. ( #131084 )

class MatrixTransitionExampleApp extends StatelessWidget {
    
    
  const MatrixTransitionExampleApp({
    
    super.key});

  
  Widget build(BuildContext context) {
    
    
    return const MaterialApp(
      home: MatrixTransitionExample(),
    );
  }
}

class MatrixTransitionExample extends StatefulWidget {
    
    
  const MatrixTransitionExample({
    
    super.key});

  
  State<MatrixTransitionExample> createState() =>
      _MatrixTransitionExampleState();
}

class _MatrixTransitionExampleState extends State<MatrixTransitionExample>
    with TickerProviderStateMixin {
    
    
  late AnimationController _controller;
  late Animation<double> _animation;

  
  void initState() {
    
    
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: 2),
      vsync: this,
    )..repeat();
    _animation = CurvedAnimation(
      parent: _controller,
      curve: Curves.linear,
    );
  }

  
  void dispose() {
    
    
    _controller.dispose();
    super.dispose();
  }

  
  Widget build(BuildContext context) {
    
    
    return Scaffold(
      body: Center(
        child: MatrixTransition(
          animation: _animation,
          child: const Padding(
            padding: EdgeInsets.all(8.0),
            child: FlutterLogo(size: 150.0),
          ),
          onTransform: (double value) {
    
    
            return Matrix4.identity()
              ..setEntry(3, 2, 0.004)
              ..rotateY(pi * 2.0 * value);
          },
        ),
      ),
    );
  }
}

PaintPattern added to flutter_test

In packageflutter_test , newPaintPattern classes allow developers to verify CustomPainter and Decoration (Used in unit testing) Wait for the drawing call made by the Widget to the canvas.

Previously a file was required to verify that the correct color and rectangle was drawn, but this can now be done usingPaintPattern, for example the following example verifies that MyWidget is drawn on the canvas A circle is drawn on:

expect(
  find.byType(MyWidget),
  paints
    ..circle(
      x: 10,
      y: 10,
      radius: 20,
      color: const Color(0xFFF44336),
    ),
);
// Multiple paint calls can even be chained together.
expect(
  find.byType(MyWidget),
  paints
    ..circle(
      x: 10,
      y: 10,
      radius: 20,
      color: const Color(0xFFF44336),
    ),
    ..image(
      image: MyImage,
      x: 20,
      y: 20,
    ),
);

rolling update

Following the first release of 2D scrolling foundation in Flutter 3.13, 3.16 brings more features and improvements. 2D foundation now supports KeepAlive Widget, as well as default focus traversal and implicit scrolling. .

Shortly after the release of 3.13, thetwo_Dimension_scrollables package was released. This package is maintained by the Flutter team and contains the first package built on the framework. Based on the 2D scrolling widget - TableView, rich decoration and style support and other bug fixes have been added.

Engine

Impeller Android

In version 3.16, Impeller on Android is ready for preview on stable, which includes information about Impeller features on Vulkan-enabled devices.

The chart shows improvements over the past year in Flutter Gallery conversion performance benchmarks running on Impeller's Vulkan backend, with users observing fewer stutters and higher steady-state frame rates.

Impeller currently performs poorly on devices without Vulkan support, but Impeller's OpenGL backend functionality will continue to be improved over the next few months.

Flutter developers can now try Impeller on Vulkan-enabled Android devices by passing the flag — enable-impeller 传递 to flutter run or by adding the following settings to in file:AndroidManiest.xml<application>

<meta-data
  android:name="io.flutter.embedding.android.EnableImpeller"
  android:value="true" />

Typically, Impeller uses Vulkan on devices running Android API 29 or higher 64-bit operating systems.

The current known issues with the Android Vulkan preview version include:

  • Platform view has not been supported yet, and the performance of frameworks containing platform view will be somewhat poor.
  • Custom shaders are not implemented yet.

Because the Android hardware ecosystem is more diverse, it is expected that Android will have a longer preview period than iOS, which is unavoidable. Additionally, Impeller's Vulkan enables features in "debug" builds beyond what Skia uses. Additional debugging features, and these features will incur additional runtime overhead,so feedback on Impeller performance should preferably come from profiles or release builds.

Impeller performance, fidelity and stability

3.16 also brings several improvements to text performance in Impeller, both on Android and iOS. In particular, improvements have been made to the management of Impeller's glyph atlas and the way text workloads are divided between the engine's UI and raster threads, so on 3.16 users will notice less stuttering in text-heavy workloads.

Chart showing reduction in average frame rasterization time (in milliseconds) in a text-intensive benchmark on iPhone 11 using Impeller.

This 3.16 release has already made 209 Impeller-related commitments to the flutter/engine repository and resolved 217 issues, including 42 user reports of fidelity, stability, or performance issues.

Engine performance

In order to support better performance on mobile devices with heterogeneous multi-processing capabilities, this timemodified Engine's performance-sensitive Support for threads (such as UI and raster threads) and devices with more powerful cores.

The improvement of this modification is very significant in some cases. It is expected that after this change is made in Skia and Impeller on Android, users will notice a reduction in lag, while on iOS devices, this impact will be less obvious because On iOS devices, the difference between more powerful cores and less powerful cores is smaller.

Impeller performance overlay

In previous versions, Flutter's performance overlay feature was not released with Impeller. This issue is fixed in this version. Performance overlay now displays correctly with Impeller enabled.

Dithering is now displayed correctly

In version 3.16, the Paint.enableDithering property is set to true by default and is no longer supported for developer configuration. Prior to this, gradients had many color bands on all devices and were used Some animations also look weird, and the solution is to make the gradient opaque and use Skia's Dithering gradient.

And to simplify the migration process, Impeller will never support dithering for anything other than gradients.

  • Before 3.16

  • After 3.16

game

Flutter Game Kit

Flutter has released tens of thousands of games over the past few years, ranging from simple but fun puzzles to more complex arcade games, including:

To help game developers be more productive, Flutter today launched a major update to the Casual Game Toolkit, a collection of new resources to help developers move from concept to launching more game templates for specific types of games, such as card games, Endless runner game, with service integration and multiplayer support such as Play Games services, in-app purchases, ads, achievements, crashlytics and more.

To learn more, you can check out https://medium.com/flutter/building-your-next-casual-game-with-flutter-716ef457e440

Web

Flutter timeline events on Chrome DevTools

Flutter timeline events now appear in the Chrome DevTools performance panel. ( #130132 )

Android

Mouse wheel support

In order to adapt to the effect of the mouse on tablets or foldable devices, flutter in version 3.16 supports matching mouse scrolling to the scrolling speed on Android devices. ( 44724 )

Predictive back navigation

The Android 14 version includes the predictive back gesture feature, and the 3.16 update brings the predictive back gesture to Flutter.

PopScope(
  canPop: _myCondition,
  child: ...
),

PopScope(
  canPop: true,
  onPopInvoked (bool didPop) {
    
    
    _myHandleOnPopMethod();
  },
  child: ...
),

NavigatorPopHandler(
  onPop: () => _nestedNavigatorKey.currentState!.pop(),
  child: Navigator(
    key: _nestedNavigatorKey,
  ),
)
···

iOS system

Application extension

Flutter can now support extensions for certainiOS apps, which means that Flutter Widgets can be used to draw UIs for certain types of iOS apps , of course this does not apply to all types of app extensions, as there may be limitations in API (e.g. home screen space) or memory.

Due to the memory limitations of app extensions, it is only recommended to use Flutter to build app extension UIs for extension types with memory limits greater than 100MB.

Additionally, Flutter uses additional memory in debug mode, so when used to build extension UIs, Flutter does not fully support running app extensions in debug mode on physical devices.

Details can be found at: https://docs.flutter.dev/platform-integration/ios/app-extensions

ecology

CurrentlyFlutter Favorite has been relaunched, and in this cycle the Flutter Ecosystem Committee willFlame< /span>,< /span>macos_ui< The /span> packages are designated as new Flutter Favorites. fpdart and , video_player, Riverpodflutter_rust_bridge, flutter_animate,

Camera X improvements

In the 3.10 stable release, initial support for Camera

dependency: 
 camera:  ^0.10.4 
 camera_android_camerax:  ^0.5.0

macOS video player

macOS support added to video_player.

development tools

Development tool extensions

New DevTools Exhibition Frame Supported by:

  • Package authors build custom tools for their packages that are exposed directly in DevTools.
  • Package authors can write powerful tools that leverage existing frameworks and utilities in DevTools.
  • Dart and Flutter developers who use DevTools to debug their app to access tooling specific to their use case (determined by the app's dependencies and which dependencies provide DevTools extensions).

ThanksProvider, Drift and For package authors of Patrol, the ecosystem has been established and DevTools extensions for these packages are now available!

Development tools updates

Some highlights of this release of DevTools include:

  • Added support for DevTools extension
  • Added a new "Home" screen showing a summary of connected apps

Other improvements include:

  • overall performance
  • Hot restart robustness
  • Text selection and copy behavior
  • viewer polish network analysis response

Discoverability in VS Code UI

Thanks to Flutter community member DanTup , the Flutter VS Code extension now has a Flutter sidebar for easy access to:

  • Open the Flutter DevTools screen
  • View active debugging sessions
  • View available devices
  • Create new project
  • Hot reload and restart
  • Run Flutter Doctor -v
  • ····

at last

This update is still a relatively "low-key" update. The biggest changes should be the default theme of M3 and Android Impeller. The other effects are actually not very big. Among them, it is recommended that everyone adapt to the M3 theme as soon as possible because of the control effect of M2. It will indeed be gradually eliminated in the future.

In addition, you can see that the core of this update is still concentrated on Android and iOS. The PC update rhythm seems to be a lot slower after being "somewhat affected"? At the same time, the plug-in update for Jetbrains has not been reflected. The resources of the core IDE have been invested in VSCode. I can only say that I will do it and cherish it.

Okay, brave young man, let’s start eating crabs.

Guess you like

Origin blog.csdn.net/ZuoYueLiang/article/details/134434681