Original link: medium.com/flutter/wha…

Welcome to Flutter 2.8! That version included 207 ficolones and 178 reviewers, for a total of 2,424 combined PR and 2,976 issues Closed.

As always, quality is at the forefront of Flutter’s work, and we spend a lot of time ensuring that Flutter runs as smoothly and robustly as possible within the range of supported devices.

Startup

This version improves the application launch delay, which was implemented in Google Pay, a major large application with over 1 million lines of code, to ensure that the impact of these changes is felt.

All of these improvements have resulted in a 50% reduction in startup latency when Running Google Pay on low-end Android devices and a 10% reduction on high-end devices.

Flutter can help avoid untimely GC during application startup by influencing the garbage collection policy of the Dart VM.

For example, Flutter now only notifies Dart VM TRIM_LEVEL_RUNNING_CRITICAL and above memory pressure signals before rendering the first frame on Android. In local tests, this change reduced the first frame time on low-end devices by up to 300 milliseconds.

To be careful, previous versions of Flutter blocked platform threads while creating platform views. This time, through detailed reasoning and testing, it was determined that some serialization could be removed. This improvement eliminated blocking of more than 100 milliseconds during Google Pay startup on low-end devices.

In addition, previous Settings of the default font manager added artificial delay when setting up the first Dart ISOLATE, and delayed the default font manager and Dart ISOLATE Settings, which both improved startup latency and made the above optimization even more noticeable.

# Memory

Because Flutter frequently loads the Dart VM’s “service ISOLATE”, this part of the AOT code is tied to the application, so Flutter reads both into memory at the same time. Therefore, for memory-constrained devices, Flutter developers are having problems with performance tracking.

In version 2.8 for Android devices, the Dart VM’s Service Isolate is split into its own packages that can be loaded separately, saving devices up to 40 MB of memory.

With Dart VM Privileged the OS, the memory footprint was further reduced by 10%. The memory used by the AOT program will probably not need to read the files again, so the pages that previously held copies of the backup data of the files can be recycled and used for other purposes.

Profiling

To better understand performance issues in the application, enabled when the application starts, version 2.8 now sends trace events to the Android Systrace logger, even if the Flutter application is built in release mode.

Additionally, in order to create less lag animations, developers may want more performance tracking information about raster caching behavior, which is expensive for Flutter, and can reuse images for blit instead of redrawing them on every frame. The new event flow in performance trace now allows you to track the life cycle of raster cache images.

Flutter DevTools

To address debugging performance issues, this version of DevTools adds a new “Enhance Tracing” feature, which helps developers diagnose UI bottlenecks caused by expensive build, layout, and drawing operations.

When either of these trace capabilities is enabled, the timeline will contain the widgets to build, render objects to lay out, and new events to draw render objects, as appropriate.

In addition, this version of DevTools adds support for analyzing application startup performance. The configuration file contains CPU samples from Dart VM initialization to the first Flutter frame rendering.

After pressing the “Profile app StartUp” button and loading the application startup Profile, developers will see the “AppStartUp” user TAB selected for the Profile, and will be able to view the app startup user TAB in the list of available user tabs, Select this user label filter, if any, to load the application startup profile.

Selecting this TAB displays configuration file data for application startup.

Web platform views

Android and iOS are not the only platforms to get performance improvements. This release also improves the performance of the Flutter Web platform.

Flutter Web achieves this with the HtmlElementView Widget, which allows developers to host HTML elements in Flutter Web applications.

If you are using the Web version of the Google_maps_FLUTTER plugin or the Video_Player plugin, or if you have followed the Recommendations of the Flutter team on how to optimize the display of images on the web, you are already using Platform Views.

In previous versions of Flutter, the Platform View immediately created a new canvas. Each additional platform view added another canvas, but creating additional canvases was expensive because each canvas was the size of the entire window.

So this version will reuse the canvas created by earlier platform views, which means developers can have multiple instances of HtmlElementView in their Web applications without compromising performance, as well as reducing scroll lag when using platform views.

3.0 the WebView

Another new version of WebView_FLUTTER is this time. The version number has been raised here because of the increase in the number of new features, and also because the way Web views work on Android may have changed significantly.

The hybrid composition mode of webview_FLUTTER is available in previous versions, but is not the default.

Hybrid Composition fixes many of the problems with the default Virtual Displays mode, and based on user feedback and bug tracking, we decided it was time to make Hybrid Composition the default. Webview_flutter also adds some more demanding features:

  • Support POST and GET to fill content (4450, 4479, 4480, 4573)
  • Load HTML from files and strings (4446, 4486, 4544, 4558)
  • Transparent Background support (3431, 3431, 4570)
  • Write cookies (4555, 4555, 4557) before loading content

In addition, in version 3.0, WebView_FLUTTER provides preliminary support for the new platform: Web. This support allows developers to build mobile and Web applications from a single code base. What does it look like to host Web views in A Flutter Web application? It looks the same from a code point of view:

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:webview_flutter_web/webview_flutter_web.dart';

void main() {
  runApp(const MaterialApp(home: HomePage()));
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();

    // required while web support is in preview
    if (kIsWeb) WebView.platform = WebWebViewPlatform();
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text('Flutter WebView example')),
        body: const WebView(initialUrl: 'https://flutter.dev')); }Copy the code

It also works as expected when running on the Web:

Note that the current implementation of webview_flutter for web has many limitations because it is implemented using the built IFrame.

It only supports simple URL loading and has no control over or interaction with loaded content

For more information, see webview_Flutter_web Readme

But webview_flutter_web has been so popular that we’re offering it as an unapproved plug-in. If you want to give it a try, please add the following line to pubspec.yaml:

dependencies:
  webview_flutter: ^ 3.0.0
  webview_flutter_web: ^ 0.1.0 from # add unendorsed plugin explicitly
Copy the code

Flutter Favorites

The Flutter Ecosystem Committee meets again and specifies the following Flutter Favorites packages:

  • Three custom router packages: Beamer, Routemaster, and GO_Router
  • drift, a powerful and popular renaming of Flutter and Dart responsive persistence libraries, built insqlite
  • Freezed, a Dart “language patch” that provides simple syntax for defining models, cloning objects, pattern matching, and more
  • dart_code_metrics
  • Several nice graphical user interfaces: FLEX_COLOR_scheme, Flutter_SVG, feedback, TOGGLE_switch, and auto_size_TEXT

Platform-specific software packages

If you are a package author, you must choose which platforms will be supported. If you are building plug-ins using platform-specific native code, this can be done using the properties in the pluginClass project. Pubspec.yaml indicates which native classes provide the functionality:

flutter:
  plugin:
    platforms:
      android:
        package: com.example.hello
        pluginClass: HelloPlugin
      ios:
        pluginClass: HelloPlugin
Copy the code

But as Dart FFI becomes more mature, you can implement platform-specific functionality in 100% Dart like the Path_PROVIDer_Windows package, so when there aren’t any native classes available but you still want to specify your package to support only certain platforms, Use the dartPluginClass property instead:

flutter:
  plugin:
    implements: hello
    platforms:
      windows:
        dartPluginClass: HelloPluginWindows
Copy the code

With this configuration, even without any native code, the package has been specified to support only certain platforms, and the Dart plug-in classes must also be provided; More information can be found in the DarT-only platform implementation documentation on flutter. Dev.

Firebase

About its series of upgrades and updates, a large piece, anyway, domestic use is not on, too lazy to write

Desktop

Flutter 2.8 is another big step towards becoming a stable version for Windows, macOS, and Linux. Including internationalization and localization support, such as the recent Chinese IME support, Korean IME support, and Chinese IME support.

An example for a stable version: completely refactoring Flutter handles keyboard events to allow synchronous responses, which enables the Widget to handle the key and cancel its propagation across the rest of the tree.

Originally regression and fixes for problems were added to Flutter 2.5 and Flutter 2.8. This was to redesign the way Flutter handles device-specific keyboard input, and to refactor the way Flutter handles text editing to complement it, all of which are required for keyboard input intensive desktop applications.

In addition, we will continue to expand Flutter’s support for visual density and expose alignment for dialog boxes to achieve a more desktop friendly UI.

Finally, the Flutter team isn’t the only one working on the Flutter desktop. Canonical’s desktop team, for example, is working with Invertase, Implement the most popular plugin for Flutter Firebase on Linux and Windows.

DartPad

DartPad improvements, the biggest of which is support for more packages. There are actually 23 packages available to import now, in addition to several Firebase services. This list contains commonly used software such as Bloc, Characters, Collection, Google_fonts, And Flutter_Riverpod. The DartPad team continues to add new packages, so to see which packages are currently supported, click the info icon in the lower right corner.

There is another new DartPad feature that is also very handy. Previously DartPad always ran the latest stable version, in which you could use the new channels menu in the status bar to select the latest Beta channel version and the previous stable version (called “old Channels”).

Removing the dev channel

The Flutter “channel” controls how quickly the underlying Flutter framework and engine change on your development machine, with Stable representing the fewest problems and master representing the most.

We recently stopped updating the Dev Channel due to resource constraints. While we did receive some questions about this, we found that less than 3% of Flutter developers use the Dev channel.

Therefore we have decided to officially retire the process Dev channel, as few developers use the Dev channel, but Flutter engineers spend a lot of time and effort maintaining it.

You can use the Flutter channel command to decide which channel you want. Here is what the Flutter team thinks about each channel:

  • Stable channel represents the highest quality build we have. They are released quarterly (roughly) with hot fixes for the key issues in the middle, the “slow” channel: safe, mature, long service.

  • Beta channels offer a fast-moving alternative for those used to a faster pace. It is currently released monthly.

  • The Master channel is our active development channel, and we don’t provide support for it, but we run a comprehensive set of unit tests against it.

When Dev deactivates the channel in the coming months, consider beta or Master channels, depending on tolerance for problems and demand for the latest and greatest.

Breaking Changes

As always, we are working hard to reduce the number of significant changes in each release. In this release, Flutter 2.8 has no significant changes other than deprecated apis that have expired and have been removed according to our major Change policy:

  • 90292 Remove autovalidate deprecation
  • 90293 delete FloatingHeaderSnapConfiguration vsync abandoned
  • 90294 Delete AndroidViewController.id deprecated
  • 90295 delete BottomNavigationBarItem. Title abandoned
  • 90296 Delete the text input format classes that are not recommended

conclusion

Read the update to Flutter 2.8. The main Changes to Flutter are performance, stability and WebView Changes. This should be friendlier in nature, since there are almost no Breaking Changes, so it’s worth checking out.