QCon London 2022: "Google’s Flutter: Mobile, Web & Desktop Frontends from 1 Codebase?"
Summary
Yes, we could build front-ends for mobile, web, and desktop from one codebase with Flutter. I wrote a sample app to demonstrate it. But I only recommended Flutter on mobile:
- Compared to frameworks like React/Angular/Vue, Flutter web only had the material design look & feel and a small number of libraries.
- On the desktop, I thought a web application was fine instead for most cases. If you still wanted a desktop application: Flutter was only stable on Windows (since February 2022), not on Mac and Linux.
- Flutter on mobile gave us “2 apps for the price of 1”. Flutter code could use native libraries because it could call native code (and vice versa). It could also show both native screens and web views. So Flutter essentially could do everything native SDK apps did, but with a faster build & deploy experience.
See my slides for why I came to this conclusion.
Logistics
Event
QCon London brought together the world’s most innovative senior software engineers across multiple domains to share their real-world implementation of emerging trends and practices to help you make the right decisions. The 2022 conference was the first one since 2020.
Talk
My talk was on Monday, April 4, at 13:40. It was called “Google’s Flutter: Mobile, Web & Desktop Frontends from 1 Codebase?”.
Abstract
The phone was the main computer for consumers at the time. Even enterprise users increasingly relied on mobile devices. Native mobile applications often provided a better user experience than web applications. But developing two different applications for iOS and Android was usually too expensive.
Cross-platform frameworks promised salvation and delivered iOS and Android apps with one codebase. Like Google’s Flutter, some even gave us web & desktop frontends, too! And Google said Flutter was “the most popular cross-platform UI toolkit” with half a million apps. So, did Flutter deliver?
Historical note (as of April 2022): After the talk, attendees could give live feedback via Mentimeter on what I should change next time. That poll is no longer reachable today.
Slides & Video
The slides were available as a PDF (7.6 MB); the PDF version is available for download here.
Historical note (as of April 2022): Back then, the slides were also available in their original Keynote format (10.2 MB) — with less text, but animated and with a look behind the curtain of individual effects, including speaker notes; that file is no longer available today.
Get Started With Flutter
Here’s my page for getting started with Flutter.
Additional Talk Information
How Cross-Platform Frontends Worked
Web
I said that React, Angular & Vue were the three most popular frameworks. I knew because for my monthly Java report, I measured the popularity of JVM languages, databases, back-end frameworks, and front-end frameworks. I measured popularity among employers through job ads from 63 countries. For developer popularity, I used online training students, Stack Overflow questions, and Google searches. Here are two of the four measurements from my March 2022 report.
The Indeed job search was active in 63 countries representing 92% of the worldwide GDP in 2020. It demonstrated the willingness of organizations to pay for a technology — the strongest indicator of popularity in my mind. Angular was the baseline. Measurements were from August 2021 through February 2022.
React won, Angular was second, Vue third. After an Angular surge the previous September, React was pulling away from Angular again. Vue was slowly gaining on Angular and had nearly reached half of Angular’s mentions. JSF was an order of magnitude behind Vue.
Udemy was one of the biggest online learning sites. They published the number of courses and the number of students beyond a certain threshold. This showed how many developers evaluated a technology. Angular was the baseline. The other frameworks didn’t cross the reporting threshold for Students at Udemy (maybe around 100,000 students). Measurements were from March 2021 through February 2022.
React won, Angular’s second, Vue is third. React was steadily increasing its lead over Angular. Vue was stuck at 40% of Angular’s students.
Here are the links that showed the courses for all and the number of students for some:
Native Look & Feel?
Native look & feel was important, especially on mobile, where a vocal minority would complain if an iOS app looked like an Android one and vice versa.
Google’s own apps, like Google Maps or Google Mail, had used mostly Material Design UI elements on iOS for years. Not anymore: to “really make products feel great on Apple platforms”, Google switched to native iOS UI elements.
If you didn’t use both iOS and Android regularly, you wouldn’t know that they were meaningfully different. Even if you tried to make them look and feel as similar as possible!
Here were three differences:
- The page heading was centered on iOS and left-aligned on Android.
- The “Edit” button was in the navigation bar on iOS and a floating action button on Android.
- When you could tap on a table row on iOS, it had a chevron on the very right. Android didn’t have such an indicator.
Forms were also different:
Here were some differences:
- The “Cancel” button had a text label on iOS and a symbol on Android.
- Fields had no label on iOS, just a placeholder when they were empty. They had both a permanently visible label and a placeholder on Android.
- Text fields on iOS had a “Clear” button. Android didn’t have such a button.
Declarative Model
I had a guide to getting started with declarative development:
Get started with declarative development
Native Framework Popularity
I said that Flutter was most popular with developers, but only second place with employers. I knew because for my monthly Java report, I measured the popularity of JVM languages, databases, back-end frameworks, and front-end frameworks — among employers through job ads from 61 countries, and for developers through online training students, Stack Overflow questions, and Google searches. Here are two of the four measurements from my March 2022 report.
The talk showed popularity with developers — courses bought at Udemy — and with employers — mentions in job ads at Indeed.
Google Trends demonstrated the initial interest in a technology over time. “More searches = better” to me.
This link produces the chart above.
Flutter won, React Native was second, Xamarin third, and JavaFX fourth. After slumping in the second half of 2020, both Flutter and React Native grew in 2021. But Flutter had just hit its July 2020 peak again, while React Native was only at two-thirds of its July 2019 peak and grew much slower. JavaFX and Xamarin had declined for five years.
Stack Overflow Trends shows which percentage of questions at Stack Overflow have a particular technology tag. It was a proxy for using a technology during evaluation and productive use. “More questions = better” to me.
This link produces the chart above.
Flutter won, React Native was second. Flutter grew much stronger than React Native. JavaFX and Xamarin had declined for 4-5 years.
How Flutter Worked
Widgets
Flutter didn’t use native UI elements (such as text fields or buttons). Instead, it emulated them. See here for more details.
Widget Sets
I built a sample Flutter application with five different, native “look & feels” from one codebase: web, iOS, Android, Windows, and Mac. I showed screenshots during the talk. You could run it yourself if you had Flutter installed!
Check out the sample application
My Flutter Experiences
My Project
The start-up I’d co-founded was called “Your Home in Good Hands”. As of April 2022: we were in private beta; our service was set to go public later that year.
Flutter: Mobile 👍🏻
I had a page dedicated to getting started with Flutter.
Flutter Hot Reload made code changes go live on the device/simulator immediately. It was the main reason why working with Flutter could be such fun! Here is a video demonstrating it.
I wasn’t ready to fully share our app yet. We had screenshots on our home page, but they were slightly out of date by then.
But I did build a prototype in 2019, which at least showed a Flutter app in motion. Although it was old by then, it was still a decent example of what a native Flutter app could look like. It took me about six weeks and was my first Flutter project. I used Google’s cloud service Firebase for login, No-SQL database, and file storage. I also built my own back-end with Java, JHipster, Spring Boot, and Angular.
Firebase 👍🏻
I also had a page dedicated to getting started with Firebase.
Mobile Power
Storing data locally and loading & saving data in the background was easy with Flutter. But we could also do that in a web application — more difficult and more restricted, but doable.
I knew because at the end of 2019, I’d built such a web application: a so-called progressive web app (PWA). A PWA used the “Service Worker” in a browser to install on your device and cache data. It took about four weeks, and it was my first PWA. I used Google Workbox for this but developed my own offline storage solution in the browser. I built my back-end with Java, JHipster, Spring Boot, and Angular.
One Source Of UI Truth
My Get Started with Flutter guide explains the use of Redux as a data store.
Here’s another example of UI inconsistencies. It came from the iPad app of the UK price comparison site Pricespy. That app wasn’t sure whether my list had seven items (top left) or just three (right).
Be Consistent
My start-up offered a web app for managers and a mobile app for cat-sitters. So arguably, consistency between them was nice-to-have.
Now most managers were also cat-sitters. So they used both apps. This made consistency a necessity!
So let’s look at the two apps. Here is the mobile app for cat-sitters:
And here is the web app for managers:
So how was this consistent — or how was it different?
- Both apps used different navigation paradigms. The mobile app had a nav bar at the top (1) and a tab bar at the bottom (2). The web app had breadcrumbs (1) and a header (2).
- Both apps shared the same colors. For instance, the mobile nav bar (1) & tab bar (2) and the web app breadcrumbs (1) all used the primary brand color. Navigation also used the same kind of blue (3).
- The apps also used the same Google font for headings (4): Montserrat.
- Finally, the apps shared symbols from Font Awesome: a walking person in this example (5).
Here are some good design books:
- The Design of Everyday Things by Donald A. Norman
- Don’t Make Me Think by Steve Krug
- The Mom Test by Rob Fitzpatrick
Back To Basics
My Get Started with Flutter guide has an architecture section that explains my proposed use of components & layers.