Validating flutter at scale

Aug 11, 2021 5 min read
Validating flutter at scale

Funda is the #1 online real estate platform in the Netherlands, with our consumers at the heart of our business decisions. Our goal is to provide a seamless user experience for buyers and sellers alike, across all devices, on every part of their customer journey. To achieve such a goal, we must devise platform-agnostic solutions with the consumer at the heart of the value proposition. Flutter is one technology which we believe will help us attain parity in design and implementation. In this blog, I detail how we went about validating flutter as a solution fit for feature teams to build features simultaneously on web and mobile apps.
Over a period of three months, we went about validating the following questions:

  1. How does a flutter module integrate with the existing mobile apps?
  2. How do we integrate multiple flutter modules with the existing mobile apps?
  3. How do the modules communicate with the native apps?
  4. How do we test performance of a flutter module at scale?

How does a flutter module integrate with the existing mobile apps?

If multiple feature teams within the organization would like to build features for the mobile apps, what would such a process look like? We considered four feature teams building four features simultaneously. How could they go about integrating the features they are building on the mobile apps? We assumed here that the features are built with flutter.

Solution direction
We looked at existing solutions within funda and devised a strategy based on our learnings. They are as follows:

  1. Every feature is a flutter module
  2. The feature is owned by the feature teams. More on team ownership can be found here (bounded contexts)
  3. A feature should have adequate test coverage, testing the business logic of the feature
  4. A feature can be integrated on the apps if and only if:
    a. It is built on the CI
    b. All unit/UI tests have been passed
    c. A binary can be built which works on the latest Android CPU architectures.
    d. An artifact is published on Azure Artifacts
  5. The mobile apps will only update to the latest version of the published artifact prior to release

Key findings
✅ DART has a low learning curve
✅ Flutter has an active community of open-source contributors
✅ Straightforward to integrate with existing iOS and Android app
❌ Increase in app size

How do we integrate multiple flutter modules with the existing mobile apps?

In this task we investigated what it means to have multiple modules integrated in the mobile apps. A module in this case is a flutter module which is launched with a specific route. For the validation step we took two independent flutter modules as examples. One was a flutter module for searching realtors on our platform, and the other was a flutter module for local insights. So there were two independent modules, with their own independent implementations. We further implemented a way to launch the two modules from the mobile apps.

Solution direction
Currently it is only possible to integrate a maximum of 1 flutter module to an existing iOS & Android app. Hence we implemented a workaround with an umbrella app as documented here:

  1. Implemented an umbrella app, which is the only module that the iOS and Android app will integrate.
  2. Created a parent/child relation with the umbrella app as the parent of all the child modules
  3. Integrated the umbrella app module to the apps and created entry points for each module
  4. Initiated the modules with specific routes.

✅ It is possible to integrate multiple modules despite the limitation from flutter, thanks to the workaround.
✅ Integration with the apps is quite straightforward.
❌ A single module leads to an increase in build & deploy time of the umbrella app (increases linearly with every new module).
❌ There is a linear increase in the size of the apps. More modules = Bigger app.
❌ Though this is not an immediate problem, the non-modular nature hinders scalability.
❌ Versioning will become hard with multiple modules that have a single umbrella interface.

How do modules communicate with the native apps?

In this task we looked at how flutter modules can communicate with native apps. We covered the following important use cases:

  1. Being able to track analytics from a flutter module.
  2. Being able to pass logged-in user information to a module, e.g. (logged in/email/userid etc.)
  3. Being able to pass privacy consent information to the modules, e.g. (cookie preferences/personalisation preferences etc.)

Solution direction
Flutter provides platform channels as a way of communicating between modules (Dart) and native apps (swift & kotlin). Here's the architectural overview of platform channels:

Since platform channels by default are not typesafe, we used Pigeon. See:

✅ The implementation with Pigeon makes everything typesafe. Further, we chose to implement a schema module which defines the contracts between modules and native apps. This makes the entire implementation non-breaking.
✅ Pigeon has a steep learning curve. Not very clear documentation for our architecture.
✅ Pigeon generates code in Dart, Java and Objective-C. The iOS and Android apps like to stay away from new Java code and new Objective-C code.

How do we test the performance of a flutter module at scale?

To use flutter for building features on mobile apps, the user experience must remain unaffected. To validate flutter as a good solution fit for building real-world features, we agreed upon the following guidelines:

  1. Re-building a key component on the mobile apps with flutter.
  2. Choosing a component in the apps that is used heavily by the users.
  3. Choosing a component in the apps that is heavy on rendering.
  4. Choosing a component that is of high business value.
    Solution direction
  5. We decided to rebuild the photo viewer on the mobile apps with flutter. It met all the above requirements for validation.
  6. We monitored the performance of the view (at scale) using firebase performance monitoring
  7. We set a baseline for crashes and compared it after shipping the flutter module using firebase-crashlytics
  8. We ran the experiment for a month across

✅ 100% crash-free experience for users who experienced the media viewer built with flutter on Android, tested across 17K users.

✅ 100% crash-free experience for users who experienced the media viewer built with flutter on iOS, tested across 16K users.

Flutter is an excellent cross-platform tool that can accelerate feature development on mobile apps. It is built to perform at scale, has a low learning curve and a great online community of software engineers.

Great! Next, complete checkout for full access to Funda.
Welcome back! You've successfully signed in.
You've successfully subscribed to Funda.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.