Codenic Clean Architecture
  • Introduction
  • The Clean Architecture
    • Presentation Layer
    • Domain Layer
    • Infrastructure Layer
  • Tutorial
    • Overview
    • Creating a Flutter Modular Project
      • Tips for Managing a Modular Project
    • Implementing the Domain Layer
      • Core Dependencies
      • Creating an Entity
      • Creating a Failure
      • Creating a Repository Interface
      • Creating Use Cases
        • CRUD Operations (Runner)
        • Data Streams (Watcher)
    • Implementing the Infrastructure Layer
      • External Dependencies
      • Creating a Data Model
      • Creating a Data Source
      • Implementing a Repository
    • Implementing the Presentation Layer
      • External Dependencies
      • Dependency Injection and Service Locator
      • Widgets
        • Snackbar Handler
        • Global Blocs Widget
        • Note Widgets
  • Packages
    • Codenic Bloc Use Case
      • Runner
      • Watcher
    • Codenic Logger
      • Usage
      • Example
      • Modifying the Logger
      • Integrating Firebase Crashlytics to the logger
    • Codenic Exception Converter
      • Failure Object
      • Exception Converter
      • Exception Converter Suite
      • Example
Powered by GitBook
On this page
  • Tip 1: CONSIDER using scripts files to manage the project
  • Tip 2: CONSIDER using a barrel file to share dependencies
  • Tip 3: DO specify the package name when accessing local assets
  1. Tutorial
  2. Creating a Flutter Modular Project

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:

#!/bin/sh

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.

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:

Image.asset('assets/splash.png'); 

Modular project:

Image.asset('packages/${PACKAGE_NAME}/assets/splash.png'); 

or

Image.asset('assets/splash.png', package: ${PACKAGE_NAME}); 
PreviousCreating a Flutter Modular ProjectNextImplementing the Domain Layer

Last updated 2 years ago

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

example