A comprehensive Flutter application template with monorepo architecture, providing a robust foundation for building scalable Flutter applications with clean architecture principles.
- ποΈ Monorepo Architecture - Managed by Melos for modular development
- π¨ Theme Management - Multiple color schemes (fire, green, violet, wheat) with dynamic switching
- π Internationalization - Full i18n support with ARB files
- π State Management - BLoC pattern implementation
- π± Responsive Design - Adaptive widgets for multiple platforms
- π§ Code Generation - Mason templates for scaffolding
- π§ͺ Testing - Comprehensive test setup
- π¦ Dependency Injection - Clean architecture with separation of concerns
This project follows clean architecture principles with a monorepo structure managed by Melos, providing separation of concerns across multiple specialized packages.
- Main App:
lib/- Entry point and main application code - API Layer:
app_api/- Generated API client code (OpenAPI/Swagger based) - State Management:
app_bloc/- BLoC pattern implementations for business logic - Shared Libraries:
app_lib/- Core utilities, themes, localization - UI Components:
app_widget/- Reusable widgets and UI elements - Code Generation:
bricks/- Mason templates for scaffolding - Third-party:
third_party/- Modified/custom third-party packages
- app_theme: Theme management with multiple color schemes
- app_locale: Internationalization support with ARB files
- app_provider: Dependency injection and app-level providers
- theme_bloc: State management for theme switching
- app_adaptive_widgets: Responsive/adaptive UI components
- app_artwork: Asset management (icons, lottie animations)
- app_feedback: User feedback mechanisms (snackbars, dialogs, toasts)
- Flutter SDK (latest stable version)
- Dart SDK
- Git
-
Clone the repository:
git clone https://github.com/your-username/flutter-app-template.git cd flutter-app-template -
Install global dependencies:
dart pub global activate melos dart pub global activate mason_cli
-
Bootstrap the project:
This will install all the dependencies for the root project and all the packages in the workspace.
melos bootstrap
-
Initialize Mason:
mason get
# Install global dependencies
dart pub global activate melos
dart pub global activate mason_cli
# Bootstrap the project
melos bootstrap
# Initialize mason
mason get# Run analysis and formatting
melos run analyze
melos run format
# Run tests across all packages
melos run test
flutter test
# Generate code (build_runner, l10n)
melos run prepare
melos run build-runner# Run tests for specific package
cd app_lib/theme && flutter test
# Analyze specific package
cd app_widget/adaptive && flutter analyze
# Build specific package
cd app_lib/theme && dart run build_runner build --delete-conflicting-outputs- Main Entry:
lib/main.dart- App initialization with providers - App Shell:
lib/app.dart- Root widget with theme management - Routing:
lib/router.dart- GoRouter configuration with declarative routing - Screens:
lib/screens/- Feature screens organized by domain
- Melos:
pubspec.yaml(workspace configuration) - Mason:
mason.yaml(code generation templates) - Analysis:
analysis_options.yaml(linting rules) - Localization:
app_lib/locale/l10n.yaml(i18n configuration)
This project uses Melos to manage the monorepo. Here are some of the available scripts:
melos run analyze: Runflutter analyzefor all packagesmelos run fix: Rundart fixfor all packagesmelos run format: Rundart formatfor all packagesmelos run test: Run Flutter tests for all packagesmelos run test:dart: Run Dart tests for non-Flutter packagesmelos run test:flutter: Run Flutter tests for Flutter packagesmelos run upgrade: Upgrade dependencies in all packagesmelos run outdated: Check for outdated dependencies in all packagesmelos run validate-dependencies: Validate dependencies usagemelos run prepare: Generate code (bootstrap + gen-l10n + build-runner)melos run build-runner: Run build_runner for all packagesmelos run gen-l10n: Generate localization filesmelos run brick-test: Run Mason brick tests (see BRICK_TESTING.md)
This project uses Mason for code generation to maintain consistency and speed up development. For a complete guide to all available bricks and their usage, see BRICKS.md.
For comprehensive documentation on testing Mason bricks, including test structure, running tests, and writing new tests, see BRICK_TESTING.md.
dart pub global activate mason_cli
mason getCreate API client code from OpenAPI specification:
mason make api_client -o app_api/app_api --package_name=app_api
# Then add OpenAPI spec to `app_api/app_api/openapi.yaml`Create a simple BLoC package:
mason make simple_bloc -o app_bloc/feature_name --name=feature_nameCreate a complete form BLoC with validation and submission logic:
mason make form_bloc --name Login --field_names "email,password"- π§± Mason Bricks Guide - Complete guide to all available Mason bricks for code generation
- π Form BLoC Guide - Comprehensive documentation for form validation and submission
- π CLAUDE.md - Development guidance and project architecture for AI assistants
# Development
flutter run
# Specific platform
flutter run -d chrome
flutter run -d android
flutter run -d ios# Run all tests
flutter test
# Run tests for all packages
melos exec flutter test
# Run tests for specific package
cd app_lib/theme && flutter testTests are co-located with their respective packages:
- Unit tests:
test/directory in each package - Widget tests:
test/directory in main app - Integration tests: Use
flutter testat root level
The workspace uses path-based dependencies for internal packages (marked as any in pubspec.yaml). All packages are managed through Melos workspace configuration, ensuring consistent versioning and dependency resolution across the monorepo.
Contributions are welcome! Please feel free to submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
- Follow the existing code style and architecture patterns
- Write tests for new features
- Update documentation as needed
- Run
melos run analyzeandmelos run formatbefore submitting PRs - Ensure all tests pass with
melos run test
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please file an issue on the GitHub repository.