I went through different cross-platform solutions during the last 5-7 years approx. Xamarin and PhoneGap were the strongest frameworks used by many apps not so long ago. A few years ago we started seeing people talking about React Native with a lot of advantages for developing cross-platform applications:
- Javascript language that anyone can use easily (including web developers)
- Great design and fast learning curve
- Really fast apps
- Able to develop native implementations if necessary
- And some other minor advantages or features.
Now it's time for me to take a look at Flutter, a framework created by Google and using its own programming language called Dart.
Looking into comparisons with React Native, if we talk about performance, app design, flexibility to create new components, and native support, maybe we can say both are pretty similar, but there are several differences that you should take in consideration before going with Flutter or React Native.
This is not a post to compare both framework, so let's talk about Flutter, its features, and what I consider good and bad depending on your background, time, and app complexity. Then you can get your own conclusion about going with one or the other, maybe you are using React Native already and this post will help you decide if you give a try to Flutter :)
What do you need to know about Dart:
- It has its own VM called DartVM
- Static types language
- Designed for client-side applications
- Dart can be used for web apps, it transpile code to javascript
Some good features:
- Great documentation for both Dart and Flutter
- Build-in solutions providing very strong built-in libraries
Now let's move to Flutter itself
Flutter is a framework running over Dart, and it provides a huge amount of components and solutions for creating mobile apps.
Similar to React Native, Flutter provides a command line tool that helps you create a new app just running 'flutter create my-app', and also you can run it either on Android or iOS with another simple line ('flutter run').
Visual Code is the recommended IDE, there's a plugin that provides all the tools you need for the Flutter project and works great. In my experience, React Native doesn't have a strong IDE, sometimes autocomplete, goto declarations, find references, is not as good as I would like. Flutter being a static-typed language makes things easier for the IDE.
If you are familiar with React, you talk about components, in Flutter you will be familiar with Widgets that are the visual components you will be using for your app, and here we have one of the main differences and advantages of Flutter, you get a lot of built-in widgets already prepared for different layouts, buttons, forms, navigation, and more. Also, this is one of the reason why this framework has a higher learning curve, because you need to discover them and understand how to use them correctly.
There are 2 main base widgets in Flutter, StatefulWidget and StatelessWidget, and as the name specifies, the first one is used for widgets that requires state changes, where some info will be stored and the widget rendering will be depending on this info. And clearly, this is what the StatelessWidget doesn't require, it's more simple and it just renders the same objects all time.
Anyway for big and more complex application, Google has designed the BLOC pattern, let's see more details about this pattern.
BLOC's Pattern
Business LOgic Component, it's a pattern using Reactive Programming to handle the flow of data within an app. It's a component that receives data from widgets using streams, and then it processes data in order to provide a response to other widgets or components interested in them.
Flutter is the best framework to create cross-platform apps as long as you have a good understanding of object-oriented programming and you are familiar with static typed languages, everything else is about reading the documentation, going through some courses or tutorials in the web. You can get a very professional application, scalable, easy to maintain, and the framework will be well-supported by a big boy like Google.