Flutter 2 is ready for production for the web, adding new platforms

A major update to Google’s cross-platform UI Package, Flutter 2 stabilizes web support and adds new platforms, including embedded, rooted and desktop. Beside, a new Dart 2.12 brings null security and Dart FFI, and

Flutter has supported iOS and Android mobile platforms since its launch. Instead, while [introduced as a technical preview in Flutter 1.5]((https://www.infoq.com/news/2019/05/flutter-1.5-mobile-web-desktop), support for web and desktop applications had not moved beyond that level. version 2, Flutter officially supports web apps targeted at Chrome, Firefox, Safari or Edge and supports the creation of native apps for Windows, macOS, and Linux.

The web platform has evolved to include richer platform APIs that enable highly dynamic applications with 2D and 3D graphics with hardware acceleration and flexible formatting and painting APIs. Flutter web support builds on these innovations, offering an app-centric framework that takes full advantage of what the modern web has to offer.

Throughout the very long technical preview phase, Google has done a great job to improve Flutter performance for the web by building a new engine for CanvasKit power using WebAssembly, while ensuring experiences built for the web can be run quickly on desktop and mobile devices. Initially, Flutter focuses on two web applications, including advanced web applications (PWAs) and single-page applications (SPAs).

As mentioned, Flutter 2 also includes support for complex devices, which was announced separately by the Microsoft Surface team. The main idea of ​​handling folding machines is the “display features”, ie areas of display that are not working, including cuts, hinges and folders. To avoid display features, developers can place their Flutter UI objects inside the display called “safe space”, which is handled automatically by the system.

According to Microsoft engineers, in many cases adding dual screen support to an app will be as easy as using the TwoPane widget, which provides a simple way to scale up design. This makes it easy to display one or two widgets depending on the available space, hence the name. Flutter’s complex support is still experimental and has not been integrated with Flutter’s official repo, however.

Along with Flutter 2, Google has released Dart 2.12, a new version of the language used to create Flutter apps. At the language level, null security is the most relevant feature of Dart 2.12, which can make it possible for all variable tests to be basically inaccessible if they do not ? suffixes for 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 DF FFI, which makes it possible to access C libraries from Dart code. While FFI Dart is considered stable and ready for production use, there are a number of fine-grained features that still work, including support for specific ABI data types such as int, long, size_t; inline arrays in structures; packed structures and so on.

Flutter 2 includes lots of new and improved widgets, too, for both iOS and Android. For example, AutoCompleteCore simplifies the implementation of automated behavior in your applications. The new Add-To-App feature is specifically for enabling Flutter to be used in only parts of your existing apps, which makes it possible to reuse the Flutter code base even if not your mobile apps are 100% Flutter. And to minimize the impact of irreversible changes on existing code basics, Flutter 2 launches Flutter Fix, which is able to launch any parts of code where possible or where a solution should be implemented, thus making it easier for developers to update their code bases with any API changes, i.e., replacing an API that is not recommended.

As a final note, Flutter adoption is growing, Google says, with more than 150,000 apps created using Flutter and available through the Play Store. Google’s own engineers have worked tirelessly to port many of Google’s existing apps to Flutter, including Stadia, Google Pay, Google One, and Google Nest Hub. In addition, there are 15,000+ packages available in the Flutter ecosystem including new SDKs for Google AdMob and Firebase, and others from Amazon, Microsoft, Square, etc.

.Source