Flutter Rust Bridge (FRB) Template App


FRB Template App - Integrating Rust with Flutter.


I would like to showcase the Flutter Rust Bridge Template app in this chapter. It's from one of the main contributors of the Flutter Rust Bridge, Viet Dinh.

πŸ‘‰ Β  Flutter Rust Bridge Template on Github

This chapter is intended as an additional exercise to become more acquainted with integrating Rust into a Flutter project, without the added complexity of integrating with IOTA.

Additionally, this chapter will cover the configuration steps for macOS and iOS, and as a consequence, it will introduce a modified workflow.

I will start this project from scratch and only take the necessary code from the FRB repository.

From the "straight forward" to a "modified" workflow

Remember the workflow used in the introduction chapter How everything works together.

Summary of Workflow

All steps of the workflow

You can simply list all the steps one after the other in a straight forward workflow.

Summary of Workflow

Straight forward workflow

This works for Android.

Android: straight forward workflow

Android: straight forward workflow

When working on macOS and iOS, you may encounter a Chicken and Egg problem, which is not a serious issue but may result in error messages that we would like to avoid.

Straight forward workflow doesn't work for macOS / iOS

Straight forward workflow doesn't work for macOS / iOS

The issue at hand is that the setup for FRB requires configuring a C header file that contains a list of all the exported symbols from the Rust library. However, this header file does not yet exist during the setup process. It will only be generated later when the Dart interface is generated.

Chicken and egg problem

Chicken and egg problem

To resolve this issue, I combine the Initialization and Development steps.

Solution

Combination of Initialization and Development steps

The Step about Setting up the Flutter Rust Bridge is now separated into two parts.

Modified workflow

Modified workflow

I will be following the modified workflow in the upcoming subchapters. There are platform specific instructions for setting up the FRB on Android, macOS, and iOS. However, there are also some general steps that apply to all target platforms, which I will cover before and after the specific subchapters.

To create the FRB example app successfully, it's important to follow each subchapter in order, starting from the beginning and moving forward.