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](../../../assets/overview/Overview.011.png)
All steps of the workflow
You can simply list all the steps one after the other in a straight forward workflow.
![Summary of Workflow](../../../assets/chicken_egg/chicken_egg.001.png)
Straight forward workflow
This works for Android.
![Android: straight forward workflow](../../../assets/chicken_egg/chicken_egg.002.png)
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](../../../assets/chicken_egg/chicken_egg.003.png)
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](../../../assets/chicken_egg/chicken_egg.004.png)
Chicken and egg problem
To resolve this issue, I combine the Initialization and Development steps.
![Solution](../../../assets/chicken_egg/modified_workflow.001.png)
Combination of Initialization and Development steps
The Step about Setting up the Flutter Rust Bridge is now separated into two parts.
![Modified workflow](../../../assets/chicken_egg/modified_workflow.002.png)
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.