Flutter 2 is ready for web production and adds new platforms

Flutter 2, a major update to Google’s Cross-Platform UI Toolkit, stabilizes web support and adds new platforms, including foldable, embedded, and desktop. Alongside it, the new Dart 2.12 offers zero security and a Dart Foreign Function Interface (FFI).

Flutter has been compatible with the iOS and Android mobile platforms since its launch. Although it was introduced as a technical preview in Flutter 1.5, the support for web and desktop applications had not passed that stage. Now with version 2, Flutter officially supports web apps targeting Chrome, Firefox, Safari, or Edge and adds support for building native apps for Windows, macOS, and Linux.

The web platform has evolved to encompass richer platform APIs that enable highly sophisticated applications with hardware-accelerated 2D and 3D graphics and flexible paint and design APIs. Flutter’s web support builds on these innovations and offers an application-centric framework that takes full advantage of everything the modern web has to offer.

During the relatively long technical preview phase, Google has done a lot of work to improve the performance of Flutter for the web by creating a new rendering engine powered by CanvasKit using WebAssembly, while ensuring that experiences built for the web are can run smoothly on desktop and mobile devices. Initially, Flutter focuses on two web scenarios, including Progressive Web Applications (PWA) and Single Page Applications (SPA).

Flutter 2 also features foldable device support, which has been announced separately by the Microsoft Surface team. The key idea for supporting foldable devices is “screen features,” that is, areas of a screen that are not functional, including cutouts, hinges, and folds. To avoid display functions, developers can place their Flutter user interface objects within a so-called “safe zone” on the screen, which is automatically managed by the system.

According to Microsoft engineers, in many cases adding dual screen support to an application will be as easy as using a TwoPane widget, which provides a simple way to scale a layout. This makes it easy to display one or two widgets depending on the space available, hence its name. However, Flutter’s folding stand is still experimental and has yet to merge with the official Flutter repository.

Along with Flutter 2, Google has released Dart 2.12, a new version of the language used to create Flutter applications. At the language level, the most relevant feature of Dart 2.12 is null security, which can be enabled to make all variable declarations non-nullable by default unless they add a ? suffix to type:

var i = 42; // non-nullable int
int? n = null; // nullable int

if (n == null) {
  return 0;
if (n > 0) { // here n has been promoted to a non-null int


Another important feature in Dart 2.12 is Dart FFI, which makes it possible to call C libraries from Dart code. While Dart FFI is considered stable and ready for production use, there are a number of detailed features that are still in the works, including support for ABI-specific data types such as int, long, size_t; online arrays in structures; packed structures and so on.

Flutter 2 also includes many new and improved widgets, for both iOS and Android. For example, AutoCompleteCore simplifies the implementation of autocomplete behavior in your applications. A new Add-To-App feature is specifically designed to allow the use of Flutter only in parts of your existing applications, making it possible to reuse your Flutter codebase even if your mobile applications are not 100% Flutter.

To reduce the impact of backward-incompatible changes to existing code bases, Flutter 2 is releasing Flutter Fix. This can mark any part of the code where a fix can or should be applied, making it easy for developers to update their code bases with any API changes, that is, replace an outdated API.

On a final note, Flutter adoption continues to grow, Google claims, with more than 150,000 apps created with Flutter and available through the Play Store. Google’s own engineers have worked hard to move many existing Google apps to Flutter, including Stadia, Google Pay, Google One, and Google Nest Hub. In addition, there are more than 15,000 packages available in the Flutter ecosystem, including new SDKs for Google AdMob and Firebase, and others from Amazon, Microsoft, Square, etc.


Source link