1. Flutter for Android Developer

Nitish Prasad
3 min readMay 25, 2019

--

Go to index to find out all the articles in this series.

This is the first post of “not yet decided” long series. In this series we will leart about flutter counterpart of Android concept. So if you have any experience in Android development, you can easily switch to flutter and from Android Development to Mobile Development. So , put your shoes on…. We are ready to start.

Major difference in the flutter is:

  1. There is no activity.
  2. There is no xml file.
  3. Flutter is written in dart.

Wait.. What … There is no xml file. which means I have to write my logic and my layout in the same file. Is it not bad? I don’t want to this. I love MVC/MVP.

Wait brother. MVC, MVP,MVVM are just design pattern which tries to simply our problem solving but they are not “The solution”. In Flutter we use ScopedModel, Bloc Pattern, Redux Pattern. Although we can use any other pattern, but these are famous in flutter development. Google recommend Bloc pattern.

But as we are starting , we need not to worry, as all the example are going to be simple and small. I will explain these pattern later in the series, when we make few full fledged software like music player , attendance application etc. So for right now , don’t focus on the design pattern. I am telling this because when we start flutter first thing that come first in our mind are xml file and activity.

One more thing, before proceeding further , i recommend to have a glance at Dart language. It is a super easy language. Just read it and come back. Specially read these topic

  1. Classes in Dart
  2. Sugar constructor
  3. Named Constructor
  4. Optional Parameter
  5. Named Parameter
  6. Printing
  7. Variable declaration and dynamic type
  8. Return shorthand or lambda expression

After knowing this, now we can start developing.

First Flutter App.

  1. Create a new flutter app in Android Studio.
  2. Clear all the auto generated code.
  3. Write code

4. Output of this program is

Hello world Flutter

Let’s Understand code line by line.

Line 1. It is a simple import statement for Material package. It help us to build material app. (Google loves Material).

Line 3. Main() is the starting point of the program. It is equivalent to

void main() {
MyApp();
}

Line 5. Define a stateless widget class. Stateless means, it don’t update like labels. Other class is Stateful widget ( we will discuss about it later).

Line 7. We need to override build method, which return a Widget. Everything is flutter is widget from simple text label to complex layout.

Line 8. Returning MaterialApp

Line 9. Here we are using named parameter home of MaterialApp class. This parameter accepts a widget. We are passing Text label in it.

So , it was first simple, sweet, ugly Flutter program. In the next part we will discuss appbar in Flutter.

Thanks for your precious time.

If you like it, give it a clap.

--

--