Skip to main content

Flutter for mobile development

As a person who is enthusiastic about programming and developing, I constantly look for new technologies and trends that emerge. Flutter came under my radar a couple of years ago when I was researching about mobile application development. 

At that moment, my mobile development skills were limited, but nevertheless, I decided to give it a try. It interested me as it promised to help the developer make an application that would run on android, iOS, an even the web with one code base. I completed one or two tutorials offered by the flutter developer site itself but as time went on due to other areas of my studies I had to focus on, flutter slowly slipped away from me. Fast forward to today, and I have received a fair amount of beginner experience on native android development and I decided to try out flutter again. Although it offers many options, I mainly focused on mobile development.

What is flutter?


 

Flutter is a UI toolkit offered by google intended to be used to develop applications for android, iOS, macOS, windows and even web using a single code base. The idea is basically, ‘write once and run everywhere’. Flutter has a framework built with dart and a rendering engine that is mostly built with C++.

Dart?

 


Dart is an unavoidable companion of flutter. Dart is the programming language that is used within flutter. It is a relatively new language compared once like java, C#, C and C++. Dart is a type-safe language with sound null safety (which means variables cannot be null unless specified explicitly). Dart is designed to compile into native ARM or x64 machine code which hints on improved performance compared to some other cross-platform development alternatives. Dart can even compile into JavaScript code which will then run on a browser. Dart files have .dart extension.

Compilation of dart has a special feature known as just in time compilation (team behind flutter calls this JITing) which helps achieve a feature known as hot reload resulting in a faster development experience.

 

What is flutter like?

To start development with flutter you have few options. IDEs will support flutter development after installing a plugin specified for that. I personally used android studio with flutter related plugins. After plugins are installed, flutter will run in android studio with its specific features and you can start by creating a new flutter project.

One of the major characteristics of flutter is that almost everything in flutter is a widget. That is how you build the UI in a flutter application. Structural elements (buttons, menus, icons, texts), stylistic elements (fonts colors) and layout specific elements can be handled as widgets. As you build your UI you are essentially building a widget tree. One widget can have a child widget in it. In case of Column or Row type widgets they can contain multiple children widgets in them as an array. You can theoretically go to any depth in this widget tree. When it comes to styling, flutter offers Material widgets for android and Cupertino widgets for iOS and these widgets are customizable.

Widgets are of two types, namely stateful and stateless widgets. Stateful widgets can change upon interactions and can maintain their state while stateless widgets never change. Stateless widgets will have an overridable build method which returns a Widget object. A stateful widget on the other hand, will have to override createState() method which refers to a class which extends State class. However, build method is where the widget tree should be constructed.

Contrast to traditional android development experience in android studio, you cannot see a preview of the UI before you launch the app or have a drag and drop UI design option in debug mode (at least by default). But flutter offers a rather convenient alternative, ‘Hot Reload’.

 

Hot Reload

This a very useful feature in flutter development. As mentioned above in this article, this is possible due to Just in Time Compilation feature of flutter and dart. Basically, this allows the developer to make changes to the code and reload it almost instantaneously. If you are familiar with the default android approach for this, you know that we must reinstall the application after every change (to see the effect of change).

But with hot reload you only have to install the debug version of the  app first time, and when you save changes done to the code, the application is automatically reloaded. Optionally hot reload button can also be used. This allows to get the visual output of the application that we are building as we build it. It even takes a step further and displays warnings and error details on the deployed app itself if errors do exist, making it easier to pinpoint errors. I personally found this feature very useful especially since I am a beginner and experimentation were easy. Nevertheless, I assume that even an advanced flutter developer would use this feature to build applications faster.

 

Error screen on device


 

Is flutter the future?

The question that should be asked before ‘is flutter the future?’ is, ‘is cross platform development the future?’. Opinions on these questions vary on a great spectrum. Some people love flutter while others prefer alternatives like react native. Then there is another group of people who say that ‘Cross platform development will not work’.

When it comes to cross platform development, the clear fact is that cross platform development cannot beat native application development. Native applications will always have better performance and access to all the features that the platform supports. Main focus of cross platform development is to maintain a single code base that run on multiple platforms. For example, flutter provides the ability to write applications in dart code and then compile the app into android and iOS machine code. Hopefully, this will take the strain of having to code the same application twice making sure to maintain the same set of features.

But things do not work the intended way exactly. Some development teams even say that with cross platform development, instead of supporting just one platform, they are supporting three platforms (in mobile development) two native platforms, android and iOS and the framework of cross platform development.

This is due to several reasons. There will be issues when using a framework like flutter such as lower performance, lack of some features. I personally found some instances where things are overly complicated than they should be, and having to use third party libraries to implement some features that will be built in features on native development.

To solve these features specialists on native development will be needed at some points. In the end you will be not having full cross platform development.

Popularity of Flutter

Despite some issues in cross platform development flutter is showing signs of popularity. In surveys conducted by stack overflow with developers, flutter had a result of 7.2% result in 2020 compared to 3.4% result in 2019 in the most popular framework category. This might be an indicator of growing popularity of flutter.

Final Thoughts

 

 


 

Flutter as a cross platform framework has a big potential. While flutter (or any other cross platform development tools) will not completely displace native development, flutter will be much useful and commercially viable in certain scenarios.

If you must build large applications with precisely optimized performance and must use a lot of features of native development, then it is better to go with native development with two full separate teams for each platform. But if you are a startup getting into mobile development and the budget and human resource is critical and limited and also need to develop and release applications fast, flutter will be a strong option for you. Even for larger organizations flutter would be a good option for smaller projects that need to be done quickly and can have limited number of developers.

In conclusion flutter growing framework that has a great potential to become a major tool among developers. Rather than trying to completely ditch native development for flutter, developers and their employers or clients should choose the option that suits their requirements better. If possible, to will be even beneficial if someone could select between native development and flutter case by case. However, it will be interesting to observe where flutter and cross platform development world is headed in the future.

 

 

 

Image credits

 

Comments

Popular posts from this blog

Installing Ubuntu desktop for Dual Booting with Windows

      Introduction Ubuntu is a Linux distribution published by the canonical team. The term ‘Ubuntu’ is an ancient African word meaning ‘humanity to others'. Ubuntu is a freely available desktop operating system that is easy to use. There are other versions of Ubuntu that are targeted for Servers, IoT and Cloud as well. In this article we are going to focus on installing Ubuntu desktop on a personal machine. Why Ubuntu? There can be several reasons for a person to use Ubuntu as their Operating System on the machine they use. The first obvious point is that is free to use. Therefore, some people may like to use this for their computational tasks. Some people can have use cases that will require a Linux system (or a UNIX like OS) such as programming in C or android platform development (which can be harder or impossible to perform on a Windows environment). For those people, a Linux distribution will be a good option (Since other UNIX like Systems can be cost prohibit

V8s, Monkeys and Chakras of the web world.

At present, many people are connected to the internet and actively using web browsers. So it will be interesting to have a look at JavaScript engines which make these browsers the kind of software they are. What is a JavaScript engine? A java script engine is a program that is mostly run in browsers which executes JavaScript codes. Most of the time, these engines use C++. These are also known as ECMA script engines since ECMA script is the standard specification for java script. First java script engines were interpreters. First java script engine was created in 1995, by Brendan Eich for the Netscape Navigator Browser. This evolved into spidermonkey engine which is used in Firefox browser. Today, most of the java script engines are developed and distributed by web browser vendors like Mozilla and google. Java script engines are run in browsers via the Document Object Model together with the rendering engines. Today java script engines are not only used for browsers, but for other fr