Fedi — Flutter open-source social network client. Part 3. Build & Config.

Yevhenii Zapletin
3 min readJul 21, 2021

--

How Fedi uses specific flutter version, handles flavors, configure app features via .env files, and how to clean project cache.

Fedi is an open-source client for Pleroma and Mastodon social networks written using Flutter available on iOS(Beta) and Android(Beta)

Series:

In this part

How Fedi uses specific flutter version, handles flavors, configure app features via .env files, and how to clean project cache when you have strange build errors.
· FVM
Sidekick
· Flavors
· .env Config
· Strange compile Errors or How to completely clean the Flutter project?

FVM

Fedi uses Flutter Version Manager(FVM) to clearly specify Flutter SDK version used in project.

You should add fvm_config.json to the project.

Pros:

  • All team members use one Flutter SDK version(new coming developers know it too).
  • You can use different Flutter SDK versions for different projects.

Cons:

  • Don’t forget to prepend fvm in the beginning of any flutter command in terminal fvm flutter run instead of flutter run
  • High disk usage if you want to have several SDKs versions

Sidekick

You can also use Sidekick GUI to manage your installed Flutter SDK versions

Flavors

With Flavors, you can maintain several app variants in one project.

Fedi has two flavors prod and dev:

  • prod is used for public releases
  • dev is used for internal testing pre-release builds and development

Flutter flavors work over Gradle flavors and XCode schemas. You can follow official documentation to integrate flavor into your project. Fedi uses Build flavors in Flutter (Android and iOS) with different Firebase projects per flavor variant.

You can set up different Run Configurations in Android Studio to run specified flavor

Pros:

  • Different Firebase credentials per flavor;
  • Different backend URLs per flavor;
  • Different config per flavor;
  • Different app IDs per flavor, so you can have both versions installed in parallel on one device.

Cons:

  • You should spend time on it.

Learn more(repository Readme) about how Fedi uses Flavors.

.env Config

Fedi stores config in .env files and uses it with flutter_config library

Fedi uses ideas explained in Configure your Flutter Environment in the Proper Way. Flutter 2.2 provides a dart-defines feature which should be a better config solution, however, as for me, flutter_config works better right now. Fedi hasn’t implemented CI/CD pipeline yet, so dart-define may be useful in this case and can work with flutter_config.

Pros:

  • It is possible to use config variables in Gradle(Android) and XCode(iOS). So you can: disable/enable libraries, specify app title and id etc;
  • It is possible to use config in Dart. For example, fetch backend URL;
  • You can use different configs per Flavor;
  • You can exclude config files from source control. It is not possible with hardcoded things.

Cons:

  • you should spend time on it;
  • flutter_config doesn’t generate .dart classes from .env. You should do it manually or use a different config library.

Check repo Readme to learn more.

Strange compile Errors or How to completely clean the Flutter project?

Flutter is still under rapid development and sometimes(especially when you changed Project config or libraries list) you will get strange compile errors. In this case, I suggest making the full project clean before trying to fix these issues. In most cases, clearing cache will fix your issues.

Final Words

Feel free to comment and fill issue if you don’t agree with something or have suggestions.

Next partPart 4. Used packages.

Start using Pleroma and Mastodon with Fedi if you still not in Fediverse: iOS(Beta) and Android(Beta). Any feedback is welcome.

If you are interested in Fedi and want to help to develop it you can start from Readme.

--

--