Tips for Managing a Modular Project

Maintaining a Flutter project with multiple modules can be difficult compared to a single module project. Here are some tips on how to effectively manage your project:

Tip 1: CONSIDER using scripts files to manage the project

It may be useful to use scripts to execute a series commands that need to run on multiple modules at a given time. This can be useful if you need to perform tasks such as cleaning the entire project, fetching the pub dependencies for all modules, or running the build_runner on one or more modules.

For example:


echo 'Clean project...'

flutter clean &
flutter clean modules/domain &
flutter clean modules/infrastructure & flutter clean modules/presentation

echo 'Get dependencies...'

flutter pub get modules/domain
flutter pub get modules/infrastructure & flutter pub get modules/presentation
flutter pub get

echo 'Run builder runner...'

cd modules/infrastructure
flutter pub run build_runner build --delete-conflicting-outputs

Tip 2: CONSIDER using a barrel file to share dependencies

Consider using a barrel file when you have one or more dependencies shared across multiple modules. This can make it easier to manage your dependencies and reduce the amount of code you need to write.

In this example, we have utilized a barrel file in our Domain to distribute certain dependencies to the main, presentation, and infrastructure modules.

Tip 3: DO specify the package name when accessing local assets

When referencing a local asset in a multi-module Flutter project, you need to specify the module where the asset is stored. Otherwise, you will not be able to access the asset.

Non-modular project:


Modular project:



Image.asset('assets/splash.png', package: ${PACKAGE_NAME}); 

Last updated