August 18, 2021
In our constantly developing, digital world the use of mobile phones plays an essential role in the everyday life of billions of people. According to Statista’s forecast on the number of mobile phone users, currently (in 2021) there are 7.1 billion mobile users worldwide. The prognosis also indicates that by the year 2025, there will be 7.49 billion users. The following graph visualises the numbers broken down into years, from 2020 to 2025.
As a result of this tendency, the development of mobile applications is also playing an increasingly important role. Beforehand, there was no single programming language that could be used to write native applications for different platforms, therefore if you wanted to create the same application for Android and iOS operating systems, you had to write the same application in two different languages. Today cross-platform technologies provide a solution for this problem. One such example is the Flutter framework, with which we can develop for iOS and Android by using a single code base. In Flutter the way of coding is different than usual, developing in this framework is a bit reminiscent of the video game development process. With the help of Flutter, developers can easily and quickly create beautiful user interfaces, not only for mobile phones but for desktops as well. Another advantage is that it provides almost native performance due to the Dart native compiler of the programming language it uses. This article aims to give the reader insights into how Flutter works and explain the advantages of the framework by describing the structure and essence of it.
The popularity of Dart can be largely attributed to the release of Flutter in May 2017, as the framework uses this language. Even though Dart and Flutter would stand their ground separately, together they could achieve even greater success in just a short period of time, not only because of their greatness but also because of their ever-growing and helpful communities.
Flutter is a free and open-source programming framework, which lets developers create cross-platform applications. But how does it actually work? Coding in a Flutter framework requires the Flutter SDK (Software Development Kit). The concept of SDK in programming means all the tools, libraries, relevant documentation, example codes that make it easier for the programmer to perform the desired task. One of Flutter’s main features is that everything you see on the screen is a widget, which is the basic building block of a Flutter application. The properties of a widget describe how it should appear on the screen based on its configuration and state.
Flutter’s architecture is different from the other frameworks, since it resembles more the operation of game engines. At the highest level, there are the Widgets, which are rendered on the canvas by Skia and are transmitted to the platform. The platform makes this canvas visible, then, if an event occurs, it is returned. The following figure illustrates the Flutter architecture.
The Flutter platform provides a specific Shell that houses the Dart VM (Virtual Machine). The Shell gives access to native platform API (Application Programming Interface) calls and a platform-specific canvas. In addition, the application lifecycle events also have a communication capability offer. The core of Flutter is the engine, which is mainly written in C++ and it is responsible for redrawing the screen when needed and updates the user interface by 60 fps (frame per second). Apps made by this framework can look the same as native iOS or Android apps, by using the right themes. Cupertino is used to create iOS themes, while Material follows the Material Design of Android. Naturally, it is also possible to create theme-independent applications.
The Flutter framework is paramount for developers. It contains everything they need in order to create an application by offering the following features:
Besides the numerous useful features, gorgeous and customisable widgets and high performance, Flutter has even more advantages. Such a benefit for example is that it needs fewer testings. Due to the use of a single code base, it is sufficient to write an automated test for both platforms only once. Another great advantage is that thanks to its simplicity, Flutter enables really fast development. Additionally, huge corporations and companies, such as BMW, Alibaba Group, eBay, Tencent and Nubank are all successfully using the Flutter framework because of its trustworthiness and production-readiness.
Though Flutter is an amazing new tool, it has some flaws as well and we should mention the areas where there’s room for improvement. One of them could be Dart itself, since it is a new programming language and developers need to learn it from scratch. Another disadvantage could be that in Flutter’s case the UI and the logic are intertwined, whereas it is more preferable to separate these concepts in case of modern frameworks. In addition, Flutter suffers from the lack of tools for continuous integration and has limited options of libraries as well. It is also worth mentioning that an APK that is created from a brand new Flutter application and contains almost nothing, takes up around 7 megabytes of space, which is quite much compared to the APK of a native Android app. And finally, in certain cases we need to communicate with native APIs in native code, especially if we do not have a suitable library, therefore we will not be able to code everything solely in Dart.
Flutter or React?
So why should developers use Flutter instead of other frameworks? As you could see, the use of Flutter has lots of benefits and more and more companies are interested in adopting the Flutter toolkit. Backed up by Google, Flutter can achieve even greater success in the future, mainly because Google's software engineers are constantly improving the framework and keeping it up to date. Moreover, Flutter is now opening to a bunch of new platforms, and if those platforms can reach a steady state too, that would be an immense achievement for the Flutter community.
Coding in Flutter is completely different from developing natively for Android or iOS, but for its simplicity, it may be worth it to at least give it a try (even if you don’t want to switch permanently). On the other hand, many companies don’t want to switch to Flutter, as the company’s developers would have to learn a whole new technology, which would take some time. The time it takes to learn the basics of Flutter would certainly return, as in Flutter most UI functions can be developed much faster and more conveniently than in native development.
Flutter also can be integrated into existing native applications as a library or module. By using Flutter, we can easily start to rewrite old legacy codebases. Besides that, Android and iOS engineers can collaboratively work on different aspects of feature development.
We hope that you found this blog post useful! Do not hesitate to follow us, so you won’t miss interesting stories in the future either. The professional content of this blog post was provided by Omar Eltigani, Flutter Developer and Csongor Vogel, Android & Flutter Developer at ff.next. Bence Siklós, Business Analyst and Melinda Havas, Head of Business Development & Marketing formed the material into this English article.