7 most important Flutter updates for 2020 you cannot miss
by Robert Odrowąż-Sypniewski, Flutter Developer at LeanCode.
2020 has been overall a pretty difficult year however it has been great in terms of Flutter development. Right at the beginning of the year, Flutter has achieved a symbolic milestone of surpassing React Native — its closest competitor — in the number of GitHub stars. Later over the year, three major (several minors) versions of the framework have been released. In this article, I will recap the most important of those changes as well as some related changes in the Flutter ecosystem.
Navigator 2.0
Probably the most important new feature of this year is Navigator 2.0. The new navigator is actually an extension introducing additional declarative API to the existing imperative navigation. There are two main advantages of the new API. The first of them is more control over the navigation stack.
Some navigation actions were difficult or awkward to implement using the old imperative API. Those difficult actions include:
- Pushing multiple pages
- Modifying the navigation stack in the middle
- Handling events that can launch the app i.e. intents and push notifications.
All of those cases are now much simpler to handle using the new declarative API. Access to the stack allows for an arbitrary number of pages to be added at arbitrary positions solving the first two issues. Inverted dependency between navigation stack and navigator resolves the issue of an unavailable navigator at the start of the application thus eliminating the need to handle intents and push notifications differently when the app is running and starting.
The second advantage is better integration with platform routing which is especially useful in Flutter for the web. In Flutter for web application users can arbitrarily change route using the navigation bar. Thanks to separate RouteInformationParser handling of those unexpected route changes is much cleaner.
Autofill
Another new feature added this year is the support for autofill in forms. Autofill was one of the few platform-specific APIs that until recently have not been accessible in Flutter apps. Now with just a couple of lines of code, we can allow platform services to save and fill credentials and other data entered by users.
Material widgets updates
New functionalities aren’t the only noteworthy changes in the framework. During this year material package has been expanded with new widgets and updated to match new Material guidelines. New widgets introduced this year are:
- NavigationRail
- InteractiveViewer
while updated widgets include:
- DatePicker
- TimerPicker
- Slider
- RangeSlider
Other widgets that have been updated are Material buttons. In Flutter 1.22 the set of standard Material buttons available in Flutter has been expanded and their theming has been revised.
Windows and Linux alpha support
Another big improvement to the Flutter framework in 2020 has been the addition of alpha support for two more desktop platforms — Linux and Windows. Support for those platforms together with macOS support introduction in late 2019 means that Flutter now supports all major desktop platforms. It’s important to keep in mind that it will be a while before the Flutter desktop will be merged to the stable branch however it works quite well already and can be considered for production use.
iOS improvements
Numerous improvements regarding the iOS platform have also been introduced. The framework has been updated to make it compatible with the new policies and features of iOS 14. cupertino_icons package has been expanded with new icons and existing icons have been updated to match the newest iOS 14 style. The 1.22 release of Flutter also includes support for the new App Clip feature of iOS 14.
Extension methods
Extension methods were added to Dart in late 2019 however their introduction caused major changes in packages during 2020. Thanks to extension methods rxdart package has been refactored to use standard Dart streams. Custom Observable type has been replaced with streams with additional functionality added using extension methods. Many packages, most notable of which are probably provider and flutter_bloc, introduced extension methods on BuildContext to access injected dependencies more concisely.
Packages
Also outside the framework, during this year, Flutter and Material teams released two important packages simplifying the development process — google_fonts and animations. google_fonts package allows for dynamic loading and caching of fonts. animations package contains ready-to-use animations of common transition effects.
What to expect for 2021?
Null-safety
The most exciting feature expected to be released in 2021 is null-safety. Null-safety, especially connected with thread safety in Dart will allow developers to write a lot safer code. For the whole year, package developers have been updating their packages to make them compatible with null-safety from day one. Thanks to that, the transition for devs will be more comfortable.
3.03.2021 event
@FlutterDev recently announced a mysterious event on 3.03.2021. Many users have been speculating on Twitter what might be announced at the event the most popular guesses are:
- stable Flutter for web
- beta/stable Flutter desktop
- Fuchsia
In my opinion, Flutter desktop merge to beta channel seems most likely.
Despite all of the obstacles of the 2020 Flutter community managed to have a very productive year and with awesome features, already in development, to be released in 2021, we can expect it to be even better.
If you are interested in other Flutter-related articles follow us on Medium and explore our LeanCode blog.