Google is a company that has repeatedly shown that it can introduce revolutions to the IT market. Hardly anyone expected that it would also be able to successfully introduce them to the process of creating multi-platform mobile applications. December 2018 brought the introduction of the first production version of the framework called Flutter – it allowed coding the application simultaneously for two leading mobile operating systems, i.e., Android and iOS. For some of you, this may not sound innovative – after all, there are many technologies offering similar possibilities, such as React Native or Xamarin. However, what distinguishes Flutter is the ability to quickly create visually attractive applications with no loss on performance – typical for the native apps. These features make it promptly gain popularity and stand out from the competition.
How it works?
While Flutter itself can be considered revolutionary, its functional principle is not. To put it in a nutshell, it is basically a diagram well-known from the popular Unity graphics engine. Instead of basing on the system components of native applications, there is only a container in which the entire user interface is drawn embedded. This gives full control over the elements embedded in the application and allows to provide consistent user interfaces for various platforms. This is achieved with the application of Skia graphics engine which is a part of e.g. Google Chrome.
This engine is based on C ++ which is ideal for embedding on many platforms, but it is not as popular as it used to be. Dart language is used instead of C ++ to communicate with the engine, which is friendlier to reach as many programmers as possible. Its syntax is simple and draws inspiration from many popular languages, which significantly facilitates learning of the technology. As you can see in the diagram above, the graphics engine is a part of the intermediate layer between the framework used by programmers and the platform on which the app is running. The key advantage of this solution is that this tool is highly independent of changes introduced to individual platforms.
From the developer’s perspective, the knowledge of Dart is enough to take advantage of all Flutter’s capabilities – both of the views implementation and the application logic. The vital element of this framework is the “widget” (component) from which the app view structure is built. The widget can be a text, a picture or more complex items. The ability to nest one widget in another opens up vast possibilities for their composition. Moreover, it creates opportunity to develop very advanced user interface elements within a short time span.
While the introduction itself was already full of superlatives of the tool, the list can be even wider:
Flutter is developed by the community, which largely determines its strength and popularity. Thanks to this, the development of this technology is very dynamic, and most importantly, it takes into account the comments of the community.
The Dart language syntax is ideal for creating user interfaces. The declarative code (i.e., one that shows what you want to achieve, not how) suits this solution.
Although Flutter does not use native user interface components, it has widgets in its library that mimic them. Thanks to this, the views creation is fast and their consistency on different platforms is retained.
Using the Skia engine for rendering views guarantees performance comparable to native apps. An application implemented by art should be able to display 60 frames per second.
A long compilation time before seeing the effects of work is one of the main problems faced by native application developers. Fortunately, Flutter faces the problem with “Hot reload”. This solution is based on the immediate reloading of the content displayed on a device or simulator. It is not only convenience but also significant time saver, which makes this technology ideal for prototyping.
Communication with the native application
In addition to displaying content and responding to gestures, many mobile apps use more advanced smartphone functionalities – e.g. reading location via GPS, contact book access, or Bluetooth communication, to name a few. To be able to use them, Flutter provides a communication channel with the native application in which it is embedded – it is called “Platform channel.” With its use, you can maintain separation from the platform without losing its full capabilities.
Embedding native views
One of the significant conveniences when migrating projects to Flutter is “Platform view” – it is a component that allows embedding native views from Android and iOS as a widget. It comes in handy when integrating with external services that provide the user interface elements. Instead of waiting for the official version of such an item to be published in Flutter, the developers can wrap it in a widget and then embed in the application.
Attractive animations are undoubtedly a great advantage of this tool. Also, their implementation process is so simple that even low-complexity applications can be enriched with eye-catching effects.
Because each element of the view is a widget (and you can freely compose it), it opens up many possibilities for the developers. When creating views, you can wrap individual groups of widgets into one, and then use it in many places of the application. As a result, it saves a lot of time when developing user interface with a unified look.
Although Flutter is distributed as open-source, Google still strongly supports this project. The participation of a large team of Google developers allows publishing subsequent versions of this tool once every few months. Taken into consideration industry standards, this is pretty frequent, especially taking into account the scale of the whole project. Therefore, such practices received very positive reviews from the developers.
CI / CD tools
Already during the first publication of the production version of Flutter, the presence of testing tools and configuration instructions for Continous Integration and Continous Delivery systems attracted attention. At a time when the industry puts great emphasis on the quality of the software produced, this is very important and it constitutes the main reason for trying this technology in current projects.
Work on simultaneous writing mobile, desktop and web applications means that Flutter may become an even more attractive technology than before. The prospect of writing one application for so many platforms is undoubtedly something that can encourage businesses to invest in solutions related to this technology.
As you could see, the advantages of Flutter are plenty, but something like perfect technology does not exist. One should keep it in mind when deciding whether a given project is better implemented natively or with the help of this tool. Here are some significant disadvantages to take into consideration:
It has not been even a year since the Flutter version 1.0 publication, which is why you have to remember that it still has many underdeveloped areas. The fast pace of publication makes Flutter more and more stable, but there are still places where it may cause problems.
The number of extensions written by the community is impressive. Still, it does not always go hand in hand with quality. It is easy to come across plugins with errors, so you should check them very closely before adding them to the project.
Embedding native views
Despite many advantages, embedding native views in Flutter is unfortunately not free from defects. By using this solution, we must prepare for performance problems which may result in less smooth operation relative to the surrounding widgets.
The aforementioned widget library speeds up work a lot, but it has one drawback – the elements of the Cupertino group (i.e., those that imitate components from the iOS system) are not 100% refined yet. It can cause problems if our goal is to reproduce this type of view entirely.
When creating applications using Flutter, the knowledge of Dart is not enough. To write or modify plugins communicating with the native app, you must have people specialized in both Android and iOS.
Flutter is undoubtedly a massive step towards creating multi-platform mobile applications. Although this technology is not free from defects and is not suitable for all applications, it is already a real competition for such solutions as React Native or Xamarin. When analyzing the fast pace of this technology development, it can be expected that it may soon become the category leader.
We plan to share another material on the practical implementation of Flutter soon, so stay tuned! 😊
Are you interested in mobile and want to use your skills creating mobile apps? Join us!