Flutter 2: what’s new

On March 3, the international Flutter community watched the Flutter Engage presentation , where Flutter 2 was presented. Stable web support, dart 2.12 support, ad creation and launch, updated DevTools, Flutter Fix and new widgets.

Flutter can be used to develop for Web, Desktop, embedded and mobile devices.
Shown is an example of an application that works on all platforms - Flutter Folio.
More than 150,000 apps have already been published on Flutter.

Web Stable version

Flutter support for the Web has moved from beta to stable release. Now Flutter, according to Google, is also a framework for creating rich interactive web applications. Let's see if Flutter takes over the web development world now?

Google primarily focused on performance and rendering fidelity improvements. In addition to the HTML renderer, a new CanvasKit-based renderer has been added. Special web features have also been added, such as the Link widget, to make an application running in a browser look like a web application.

Here and here you can see an example of creating a web application.

Sound null safety

Long-awaited update - Sound null safety for Dart

Sound Null Safety is a significant addition to the Dart language that further strengthens the type system by separating nullable types from non-nullable types. This allows developers to prevent runtime crashes, a common cause of application crashes. By incorporating checks into the type system, these errors can be detected at design time. Null safety is fully supported in the stable release of Flutter 2, which contains Dart 2.12.

More than 1000 null safety packages have already been published in the pub.dev package repository, including hundreds of packages from the Dart, Flutter, Firebase and Material teams.

More details here .

Flutter Desktop

Flutter Windows Desktop App | Early Preview - YouTube
Developers can now try Flutter Desktop

Flutter desktop support is available in the stable channel under the early release flag. This means that everything is ready to try Desktop development in their applications until the stable version is released this year.

The following features have been added:

  • Improved text handling so that it is the same as on all supported platforms: selections, drag-and-drop, keyboard and mouse interactions. For example, mouse dragging now starts immediately instead of waiting for the delay required when handling touch input.
  • A context menu has been added to the TextField and TextFormField widgets.
  • Grab handles have been added to the ReorderableListView widget to allow you to move list items without waiting for a long press.
  • Updated the scrollbar to display correctly for the desktop form factor.
  • The interactive features expected on the desktop have been implemented, including the ability to drag the slider, click the track to page up and down, and display the track when you hover over any part of the screen.
  • Added the ScrollbarTheme class with which you can customize its appearance. Work with additional PC functions: for example, double-clicking on a data file in Windows Explorer to open the file in an application.
  • Improved handling of resizing - it is now smoother for both Windows and macOS.
  • The documentation has been updated to describe what you need to do to get started developing for Desktop.

Platform responsive apps: Flutter Folio

An example of an application that works well regardless of screen size and input method

Flutter supports three production platforms (Android, iOS and web) and three more in beta (Windows, macOS and Linux). To create responsive apps that display well on small, medium and large screens, we created the Flutter Folio.

Folio is a simple example of an application that works well across multiple platforms from a single code base. Here you can see the source code Folio, to make their own applications platform adaptive.

Mobile advertising with Google Mobile Ads

Beta version of Google Mobile Ads SDK for Flutter

A beta version of the Google Mobile Ads SDK for Flutter has arrived. This is a new plugin that provides inline banners and native ads in addition to existing overlay formats (banner overlays, interstitials). This plugin combines AdManager and Admob support and allows you to create various ad formats in Flutter apps.

The developers say they have already tested this format. For example, the Latin American music platform for independent artists Sua Musica (over 15,000 artists and 10 million MAUs) has launched its new Flutter app with the Google Mobile Ads SDK plugin for Flutter. Impressions increased by 350%, CTR by 43%, and effective CPM by 13%.

On flutter.dev create a page of advertising, where you can find useful resources such as guidance on the implementation of the plugin code table embedded banners and native advertising code table overlay banners, interstitials and video with the award.

New iOS features

178 improvements

Among them:

  • Work with state restoration.
  • Create IPA directly from the command line without opening Xcode.
  • CocoaPods version update.
  • New widgets for iOS.

AutocompleteCore and Scaffold Messenger

New widgets

Flutter 2 has two additional new widgets: AutocompleteCore and ScaffoldMessenger.

AutocompleteCore is a search box autocomplete that appears as a drop-down suggestion box.

ScaffoldMessenger was created to solve a number of problems and make the SnackBar easier to use. The SnackBar now retains its state when navigating between different Scaffolds and remains on the screen.

AutocompleteCore and ScaffoldMessenger might seem like minor updates. But we think that everyone who worked with Flutter and tried to implement Autocomplete on their own will understand their beauty. ScaffoldMessenger should probably have been done from the start. Because working with the snackbar, which was implemented through Scaffold, raised a lot of questions.

Adding multiple Flutter modules to existing native apps

Adding the Add-to-App function

The Add-to-App feature is a great way to reuse Flutter code across both mobile platforms while maintaining your existing native code base. Interweaving Flutter and native screens makes it difficult to maintain navigation states, and integrating multiple Flutter models is memory intensive.

In Flutter 2, the static memory cost for creating additional Flutter modules has been reduced by ~ 99% to ~ 180 KB per instance.

New APIs to do this are in beta and documented at flutter.dev along with a set of sample projects demonstrating this new pattern. As recommended by the developers, you should create multiple instances of the Flutter engine in your applications.

Flutter Fix

Command line tool that allows you to replace deprecated APIs in your project codebase

In order not to interfere with more than 500,000 developers and to avoid disrupting the growing number of lines of code with changes to the infrastructure API, they came up with Flutter Fix. According to Google, Flutter Fix finds all obsolete methods and variables and helps to update them.

Flutter Fix is ​​a combination of several things. First, there is a new command line parameter for the dart command line tool called dart fix. He knows where to look for a list of deprecated APIs and how to update code with those APIs. Second, there is the list of available fixes itself, which is included in the Flutter SDK since version 2. And finally, there is an updated set of Flutter extensions for the VS Code IDE, IntelliJ, and Android Studio that know how to expose the same.

Flutter DevTools

Updates and new features

DevTools is a tool that should be used to debug Flutter applications, in the new version it was renamed Flutter DevTools and the following features were added:

  • IDE notifications with links to problems (previously only on the command line).
  • View high definition images to monitor memory usage.
  • Improved work with layouts in Flutter Inspector.
  • Added average FPS information and usability improvements to Flutter's frame diagram.
  • Raising unsuccessful network requests in the network profiler with red error marks.
  • New memory view charts are faster, smaller, and easier to use, including a new map to describe activity at specific times.
  • Added search and filtering to the Logging tab.
  • Renamed Performance View to CPU Profiler to make it clearer what functionality it provides.
  • Added time grid to CPU Profiler flame charts.
  • Renamed Timeline View to Performance to make it clearer what functionality it provides.

Android Studio / IntelliJ Extension

The Flutter plugin for the IntelliJ IDE family has also received a number of new features for Flutter 2. For starters, there is a new project wizard that matches the new wizard style in IntelliJ.

Click to rate this post!
[Total: 33 Average: 5]

Leave a Comment