Google's Cross Platform App Framework Ready To Go

Google’s Flutter is about to be released as a Version 1 product, ready for you to use. The question is should you be interested in a way to create almost native apps that run on iOS or Android? I suppose it depends on what “almost native” means?

Flutter is a strange project for Google to support. It is designed to allow the creation of apps that work on either iOS or Android. As Google only really has an interest in getting you to write Android apps, it is difficult to see what the motivation is to help Apple out with gaining apps.

The whole thing seems to be motivated by a desire to make the Dart language more useful. Dart was going to be Google’s JavaScript replacement, but it didn’t get the external support it needed so it was quietly sidelined.

Then, at the start of the year, it seemed to spring back into life with Flutter, a cross-platform app development framework using Dart as its language.
Now, about six months later, we have a release preview, which must be something like a release candidate.

There is also an official blog post talking the project up. In mentions a 50% increase in active Flutter users, entering the top 100 repos on GitHub and lots of user groups, meetings and events. More importantly some Flutter-based apps are appearing in the App Store and Play.

While all this is good, it is still difficult to know if Flutter has a chance of taking off. An increase in interest isn’t necessarily the same thing as a lot of interest.

The real question is why would you adopt Flutter?. The alternatives are to create a native app or build a web app. The problem with native apps is that they are harder to create and you need at least two, not that similar, implementations. Web apps are progressing in the sense of Progressive Apps, but they still have their problems.

If you are prepared to take a non-standards-based approach then Flutter might be for you. It is an alternative to approaches like PhoneGap/Cordova. Where PhoneGap/Cordova wraps a standard HTML/JavaScript app in an extended browser to create something that looks like a native app, Flutter wraps a custom UI SDK/Dart in a C++ wrapper.

Other obvious Flutter alternatives are React Native and Xamarin.
Developing with Flutter seems fairly easy. You can even use Android Studio with an add-in or an alternative IDE. Most of Flutter is concerned with creating a UI in code. You can create something that looks good on Android or iOS. Once you get beyond the UI, things get a bit more tricky.

There is an interop module that provides ways of calling the native API from Dart. On the Dart side this works in a platform-independent way, but the cost is that you have to supply the native implementation of the function.

Easily compose your UI with Flutter’s modern reactive framework and rich set of platform, layout, and foundation widgets. Solve your tough UI challenges with powerful and flexible APIs for 2D, animation, gestures, effects, and more.

class CounterState extends State<Counter> {   int counter = 0;   void increment() {     // Tells the Flutter framework that state has changed,     // so the framework can run build() and update the display.     setState(() {       counter++;     });   }   Widget build(BuildContext context) {     // This method is rerun every time setState is called.     // The Flutter framework has been optimized to make rerunning     // build methods fast, so that you can just rebuild anything that     // needs updating rather than having to individually change     // instances of widgets.     return new Row(       children: <Widget>[         new RaisedButton(           onPressed: increment,           child: new Text('Increment'),         ),         new Text('Count: $counter'),       ],     );   } }

Browse the widget catalog and learn more about the reactive framework.
So you can more-or-less invent your own platform implementation of the native APIs.

This isn’t that difficult, but it would be so much better if Flutter provided a standard regularization of the iOS and Android APIs – but this would be a huge project. More reasonable would be a core implementation of the API calls that are most used.

Because of this native API interop I’m not sure that you could build apps that are as sophisticated as full native apps – how would you use Android Fragments, for example? It seems to me that the ideal Flutter app is one that is mostly UI with a few native API calls to provide data.

Certainly, before committing to a Flutter app development project, you should make sure that you understand how the interop works and make sure you have both Android and iOS expertise to implement the native components of the project.

Flutter is about to be released and we have yet another way to create apps. It will be interesting to see how high it can go.