Flutter for .NET Developers

Also available in portuguese

As a .NET developer, I describe what you need to know to start creating applications in Flutter, Google’s UI Toolkit.

Flutter for .NET Developers

I have this friend Kleber Silva that is always talking about Flutter on Facebook and, he convinced me to retake a look in that technology, but now as a .NET developer.

Don’t worry if you aren’t a .NET developer you are going to understand more about Flutter and what it can be helpful for you.


#Flutter – WTF?

Google itself says that Flutter is a set of a toolkit to create beautiful and native UI for Web, mobile, and desktop platforms.

In other words, it is a framework for developing cross-platform applications Web, mobile (Android and iOS), and desktop.

You write one code in Flutter and run it on Android, iOS, Web, and Desktop platforms.

Flutter for .NET Developers 1

Any comparison with Xamarin Forms is NOT coincidence đŸ™‚

To develop in Flutter is necessary to have some knowledge in Dart programming language that Google optimized it for frontend.

// A function declaration.
int timesTwo(int x) {
  return x * 2;
}
 
// Arrow syntax is shorthand for `{ return expr; }`.
int timesFour(int x) => timesTwo(timesTwo(x));
 
// Functions are objects.
int runTwice(int x, Function f) {
  for (var i = 0; i < 2; i++) {
    x = f(x);
  }
  return x;
}
 
main() {
  print("4 times two is ${timesTwo(4)}");
  print("4 times four is ${timesFour(4)}");
  print("2 x 2 x 2 is ${runTwice(2, timesTwo)}");
}

As you can see in the code above, Dart is not a big deal, and it is possible to start learning without any difficulty.


# The Installation

Like every framework, it is necessary to install some little things.

When I had read Flutter documentation, I started to become apprehensive, because I had remembered the time I had tried to install and configure Xamarin Forms.

But, with Flutter was easier than Xamarin Forms, let’s see what is necessary to do.

In my opinion, it was easy because of the complete documentation that Google provided to us.

Flutter for .NET Developers 2

If you already program in other platforms like Xamarin, Google has one specific documentation each of it. I thought that was awesome!

We have to install:

– Android Studio (about 800MB);
– Android SDK from Android Studio menu;
– Flutter and Dart plugins also from Android Studio;
– Android Studio USB debugger;
– Enable developer mode in an Android cellphone.
– Enable VM acceleration in the PC (if you use PC).
– Flutter SDK (about 700MB);

You can’t lose yourself; there is a step by step to accomplish all these installations and configurations.

Flutter for .NET Developers 3

As a .NET developer, to create applications in Flutter, you can use Visual Studio Code instead. It is just necessary to install two plugins: Flutter and Dart.


# The SDK and Emulators

After all the installations we had had, to run a mobile application in Flutter, you need first starting a mobile Emulator.

To do that, open the Android Studio, click in the AVD Manager option menu, and then click in the start button or create a new Emulator with all your needs.

Flutter for .NET Developers 4

Remember to set the option Hardware GLES 2.0 for the Emulated Performance Graphics property on your mobile Emulator.

To debug Flutter using Visual Studio Code, choose what kind of android emulator you want to use and press F5.

Flutter for .NET Developers 5

After starting the Emulator for the first time, you don’t need to worry about stopping and starting the application all the time when performing any changes in your code.

Just save the source code file and see all changes in the Emulator screen. That feature is called Stateful Hot Reload.

The Emulator running a mobile application of the Test Drive Tutorial:

Flutter for .NET Developers 6


#Next Steps

With Flutter, I can use Visual Studio Code, had performed all installations in less than one hour, had read the rich documentation with a lot of samples, now I will create a complete mobile application for the next article about it.

I want to like to say something to Microsft. For Blazor, it’s time to create rich documentation like Google’s.

I hope you enjoyed that overview of Flutter.

Thank you đŸ™‚

About the Author:
He works as a solution architect and developer, has more than 18 years of experience in software development on several platforms and more than 16 years only for the insurance market.