Google has finally released its Flutter version 2.0 on March 3 at an event named Flutter Engage. It’s an open-source UI development kit that helps app developers develop cross-platform apps using a similar codebase. With this upgrade, Google not just maximized the features of Flutter but also designed the new version in a way so it can make a move beyond mobile to support apps wherever they belong to – the desktop, web, and growing form factors like foldables.
Using Flutter 2, you can utilize a similar codebase for shipping native applications to 5 Operating Systems: Android, iOS, macOS, Windows, and Linux.
Moreover, it gives web experiences targeting browsers like Edge, Safari, Firefox, or Chrome. You can embed Flutter in TVs, cars, and smart home apparatus, which gives the most portable and pervasive experience for an encompassing computing world.
What’s New in Flutter 2?
There are many exciting things causing as part of the release of Flutter 2. To see what is new in Flutter 2 and how it targets developers across all platforms, keep reading!
Flutter’s Web Support
Flutter’s production quality web support is the largest declaration in Flutter 2. Previously the web’s foundation was document-centric. But the web platform has developed to circulate richer platform APIs that allow extremely sophisticated applications using hardware-accelerated 3D and 2D graphics, paint APIs, and flexible layout.
Flutter’s support for the web establishes these innovations, providing an app-focused framework that reaps the full benefits of everything that the modern web should provide. Initially, this release concentrates on 3 app scenarios:
- Single Page Apps (SPAs)
- Progressive Web Apps (PWAs)
- Bringing current Flutter mobile apps to the web
Moreover, they added web-specific features like control over address bar URLs, text autofill, PWA manifests and routing. Also, they included a Link Widget to ensure a mobile app running in the browser feels like a web app.
Flutter’s Desktop Support
Google can try Flutter’s desktop support as a deployment target for all Flutter apps. There have been many enhancements to bring Flutter desktop to great quality, making sure that text editing operates like a native experience on every supported platform, incorporating foundational features like text selection pivot points.
Google has also added a built-in context menu to the TextFormField and TextField widgets for Cupertino and Material design languages. Moreover, grab handles have been added to the ReorderableListView widget. This widget has always been excellent at moving things around with the small efforts of a developer.
An updated scrollbar is another enhancement for platform-idiomatic functionality that precisely displays for the desktop form-factor. The updated scrollbar widget offers many engaging features that you can expect on the desktop, incorporating the capacity to click on the track to page up and down and drag the thumb and display a track when a mouse flutters over the scrollbar.
For extra desktop-specific functionality, Flutter 2 release also allows command-line argument managing for Flutter applications so easy things like a double-click on a data file in the Windows File Explorer can be utilized for opening the file in your app.
Moreover, Google has updated docs on what developers require doing for preparing their desktop apps for deployment to the precise OS-specific stores.
In case you want to stay on the stable channel for availing of the desktop beta, you will not get new bug fixes or features as fast as moving to the dev channels or beta. Hence, to actively target Linux, macOS, or Windows, you are suggested to move to a channel that offers updates faster.
Flutter’s Extended Portability
Flutter is extending increasingly to other types of devices, beyond the web and conventional mobile devices. Google highlighted 3 team-ups that showcase Flutter’s maximized portability.
Firstly, Canonical is teaming up with Google for bringing Flutter to desktop, with developers providing code for supporting deployment and development on Linux. Canonical wants to offer sturdy yet beautiful experiences on various hardware configurations. And Flutter is their primary option for upcoming mobile and desktop apps.
Secondly, Microsoft will increase its support for Flutter. Alongside the current collaboration for providing premium quality Windows support in Flutter, Microsoft will introduce contributions to the Flutter engine that gives support to the growing class of foldable Android devices. These devices launch new design patterns, with applications that can either take benefits of dual-screen nature for offering side-by-side experiences or increase content.
Finally, the world’s best-selling vehicle manufacturers, Toyota, declared its strategies for bringing the best-in-class digital experiences to cars, by creating infotainment systems enabled by Flutter.
Toyota selected Flutter due to its consistency of experience and high performance, developer ergonomics and quick iteration, and smartphone-tier touch systems. With Flutter’s embedded API, Toyota can customize Flutter for the robust requirements of an in-vehicle framework.
Flutter fix combines several things. There is an exclusive command-line option to the Dart CLI tool named Dart Fix that knows where to seek a list of deprecated APIs and how it is possible to upgrade code with those APIs. Then it’s the list of accessible fixes, which is packed with the Flutter SDK as of version 2.
And ultimately, it’s an updated set of Flutter extensions for IntelliJ, the VS Code, and Android Studio IDEs that can showcase a similar list of accessible solutions as fast fixes with little light bulbs that can help developers change their codes using their mouse.
Since now Flutter supports 3 platforms (iOS, Android, and the web) for production applications and 3 more in beta (Linux, macOS, and Windows), how is it possible to write an app that changes itself to several form factors (large, small and medium screens), various idioms (desktop, web, and mobile), and various input modes (mouse, keyboard, and touch)? Google commissioned the Flutter Folio scrapbooking app for answering this question.
Folio is an easy example of an application that will run properly on different platforms from just one codebase. This app is known as platform adaptive as it adapts properly to whatever platform it is running on.
Now developers can take the benefits of Flutter, by adding it to their current Android and iOS apps. This feature is known as Add-to-App, which is a great way of reusing the Flutter code across both platforms while still storing your current native codebase. The new APIs that allow this are in preview on the beta channel.
These APIs are documented on flutter.dev alongside a set of sample projects showcasing this new pattern. With this change, Google can suggest building different instances of the Flutter engine in native apps.
Release of Dart 2.12 with Support for Sound Null Safety
Google also launched Dart 2.12 with support for sound null safety. Sound null safety can reduce cringe null reference exceptions. It provides assurances at development and runtime that types can just comprise null values in case the developer selects expressly.
This update also incorporates a consistent application of FFI, which enables developers to write high-performance code that can interoperate with C-based APIs, new profiler tooling written with Flutter and integrated developer, and many size and performance enhancements that upgrade your code further for free.
Google Mobile Ads to Beta: The Emerging Flutter Ecosystem
Google declares the beta launch of Google Mobile Ads for Flutter. This new SDK works well with AdManager and AdMob for providing different ad formats, incorporating native, banner, rewarded video ads, and interstitial. Google has been revealing this SDK with many primary customers like Sua Musica, the largest music platform for many artists in Latin America.
Now Google is prepared for opening the Google Mobile Ads for Flutter SDK for more adoption. Moreover, the organization also declared updates to its Flutter plug-ins for many key Firebase services, such as Cloud Firestore, Authentication, Cloud Messaging, Cloud Functions, Crashlytics, and Cloud Storage, incorporating assistance for sound null safety and an update of the Cloud Messaging Package.
Google has done lots of work for bringing Flutter for making DevTools the production quality worthy of Flutter 2. A new feature that helps developers reduce their problems before they have released DevTools is the capacity for IntelliJ, Android Studio, or Visual Studio Code for noticing when there is a basic exception and provide for bringing it up in DevTools for debugging it.
In DevTools, another new feature is the capacity to see a picture easily that is at a higher resolution than it is shown. This helps track down extra memory use and app size. Allow the Invert Oversized Images in the Flutter Inspector for turning on this feature.
Google has also added the capacity to display fixed layouts, allowing developers to debug all types of layouts. Some more of the new features available in Flutter DevTools 2 are as follows:
- New memory view charts are quicker, easier to use, and smaller, incorporating a new hovercard for explaining activity at a particular time.
- The ‘Performance’ view is renamed to ‘CPU Profiler’, which makes it clearer about the functionality it offers.
- Usability enhancements and average FPS data are added to the Flutter Frames Chart.
- Search and filtering are added to the Logging tab.
- The ‘Timeline’ view is renamed to ‘Performance’, which makes it clearer about the functionality it offers.
- Timing grid is added to CPU Profiler flame charts.
- Track logs form is started before DevTools, so developers can see the total logging history when they start it up.
- Calling out unsuccessful network requests in the network profiler having red error labels.
In conclusion, Flutter 2 is now available for developers only. It is open-source and free. In case you still haven’t tried it, use this prime upgrade for an exclusive app development experience.