flutter_archkit 0.2.1
flutter_archkit: ^0.2.1 copied to clipboard
An automated Flutter architecture generator (Clean, MVVM, MVC with Bloc, Cubit, Riverpod, Provider, GetX), feature module generator, and multi-flavor CLI configuration tool.
Flutter ArchKit #
The Ultimate Flutter Architecture Generator, Feature Scaffolder, Code Generator & Multi-Flavor CLI Toolkit
π Overview #
flutter_archkit is an enterprise-grade command-line interface (CLI) toolkit and code generator designed to eliminate architectural boilerplate and streamline Flutter app development.
Whether starting a greenfield project or scaling an existing production codebase, flutter_archkit automates:
- ποΈ Project Scaffolding: Interactive wizard for Clean Architecture, MVVM, or MVC.
- β‘ Feature Modules: One-command feature generator matching your project's architecture and state management.
- π§
@ArchkitCode Generation: Automatically writes cascading UseCases, Repositories, DataSources, and API calls from annotated presentation handlers. - π£οΈ Router Infrastructure: Scaffolds Navigator 1.0/2.0, Go Router (with Bottom Navigation Shells), Auto Route, or GetX Routing.
- π Network Layer: Scaffolds production Dio HTTP client with generic
ApiResponse<T>, customApiException, interceptors, and typed contracts. - π― Multi-Flavor Environments: Configures Android Flavors, iOS Schemes &
.xcconfig, DartServerConfig, VS Codelaunch.json, and Android Studio run configurations.
π Documentation Guides & Topics #
Explore dedicated, in-depth documentation guides for each architecture pattern and feature:
| Topic / Guide | Description |
|---|---|
| ποΈ Clean Architecture Guide | Deep dive into Data, Domain, Presentation, & DI layers with BLoC, Cubit, Riverpod, Provider, & GetX. |
| π¨ MVVM Architecture Guide | Deep dive into Models, Services, ViewModels, Views, and reactive state management integration. |
| ποΈ MVC Architecture Guide | Deep dive into Models, Controllers, Views, and lightweight action dispatching. |
π§ @Archkit Code Generator Guide |
Complete guide on annotating presentation handlers and cascading methods across domain/data layers. |
| π£οΈ Route Systems Guide | Comprehensive setup for Go Router (with Bottom Nav Shell), Auto Route, GetX Routing, Navigator 1.0/2.0. |
| π Production Network Layer Guide | Detailed guide for Dio HTTP client, ApiResponse<T>, ApiException, and interceptors. |
| π― Multi-Flavor Setup Guide | Complete guide for archkit flavor, flavor.yaml, Android Gradle, iOS Xcode schemes, & IDE run targets. |
π Table of Contents #
- Documentation Guides & Topics
- Features & Architecture Matrix
- CLI Command Cheat Sheet
- Installation
- Usage Guide
- Directory Structures
- Example Application
- Contributing & Issues
- License
π§© Features & Architecture Matrix #
| Capability | Supported Technologies & Options |
|---|---|
| Architectures | Clean Architecture (Data / Domain / Presentation / DI), MVVM (Models / Services / ViewModels / Views), MVC (Models / Controllers / Views) |
| State Management | BLoC, Cubit, Riverpod, Provider, GetX |
| Routing Systems | Navigator 1.0, Navigator 2.0, Go Router (with StatefulShellRoute bottom navigation support), Auto Route, GetX Routing |
| Networking | Dio 5.x, Generic ApiResponse<T>, ApiException, Logging Interceptor, Auth Interceptors, ApiInterface contract |
| Code Generation | @Archkit annotation parser: Cascading generation of UseCases, Repositories, Remote DataSources, and Service interfaces |
| Multi-Flavor | Android (flavor.gradle.kts), iOS (XCConfig, Schemes, project.pbxproj), Dart (ServerConfig), IDE Run Configs (VS Code & Android Studio) |
| Configuration | Smart .metadata tracking: Auto-detects project architecture without passing repetitive flags |
β‘ CLI Command Cheat Sheet #
| Command | Aliases | Description | Example |
|---|---|---|---|
archkit create <app_name> |
-c, --create |
Creates a new Flutter app with chosen architecture & state management | archkit create my_app -a Clean -s Bloc |
archkit feature <name> |
-f, --feature |
Scaffolds a new feature module matching project architecture | archkit feature auth or archkit -f profile |
archkit route |
-r, --route |
Scaffolds routing system & installs router dependencies | archkit route -t "Go Router" --shell |
archkit network |
-n, --network |
Scaffolds production Dio HTTP network layer | archkit network --override |
archkit generate |
g, gen, -g |
Generates domain & data layer methods for @Archkit annotations |
archkit g -p lib/features/auth |
archkit flavor |
-fl, --flavor |
Configures multi-flavor environments (Android, iOS, Dart, IDEs) | archkit flavor --init or archkit -fl |
π¦ Installation #
Global Activation (Recommended) #
Activate flutter_archkit globally to use the archkit CLI from anywhere in your terminal:
dart pub global activate flutter_archkit
Note: Ensure your global pub cache bin path is added to your system's
PATHenvironment variable.
As a Project Dependency #
Add flutter_archkit to your Flutter project's pubspec.yaml under dev_dependencies to utilize the @Archkit annotation and flavor generators:
dev_dependencies:
flutter_archkit: ^0.2.1
Then run:
flutter pub get
π Usage Guide #
1. Creating a Project (archkit create) #
Scaffold a complete, production-ready Flutter application with interactive terminal prompts:
archkit create my_app
? Select Architecture:
β― Clean Architecture (Data, Domain, Presentation, DI)
MVVM Architecture (Models, Services, ViewModels, Views)
MVC Architecture (Models, Controllers, Views)
? Select State Management:
β― Bloc
Cubit
Riverpod
Provider
GetX
? Organization Identifier: com.example
? Target Platforms: android, ios, web
Non-Interactive CLI Mode
Automate CI/CD or scripted project generation using command-line flags:
archkit create my_app \
--org com.example \
--architecture Clean \
--state-management Bloc \
--platforms android,ios,web
2. Scaffolding Feature Modules (archkit feature) #
Generate modular, architecture-compliant feature packages in seconds. archkit automatically detects your project's architecture and state management from .metadata!
# Full command
archkit feature auth
# Or quick shortcut
archkit -f user_profile
Clean Architecture Feature Output (lib/features/auth/):
domain/entities/auth_entity.dartdomain/repositories/auth_repository.dartdomain/usecases/auth_usecase.dartdata/models/auth_model.dartdata/data_sources/auth_remote_datasource.dart&_impl.dartdata/repositories/auth_repository_impl.dartpresentation/bloc/auth_bloc.dart,auth_event.dart,auth_state.dartpresentation/page/auth_page.dartdi/auth_di.dart
3. Setting Up Route Systems (archkit route) #
Set up a robust navigation infrastructure tailored to your preferred routing engine:
archkit route
# Or alias
archkit r
Supported Route Engines:
Navigator 1.0: Traditional named routes withRouteGeneratorandMaterialPageRoute.Navigator 2.0: Declarative routing with customRouterDelegateandRouteInformationParser.Go Router: URL-driven routing supporting deep links, route redirection, and optionalStatefulShellRoutebottom navigation.Auto Route: Type-safe code-generated navigation.GetX Routing: LightweightGetPagenavigation.
4. Generating Network Layer (archkit network) #
Scaffold a battle-tested Dio network client architecture in lib/core/network/ and lib/core/util/:
archkit network
# Or alias
archkit n
5. Smart @Archkit Code Generation (archkit generate) #
Speed up development exponentially by designing your UI/Presentation layer first and generating all corresponding domain and data layer classes with a single command.
Step 1: Annotate your Presentation Method
Import package:flutter_archkit/flutter_archkit.dart and annotate event handlers or functions in your BLoC, Cubit, Riverpod Notifier, ViewModel, or Controller:
import 'package:flutter_archkit/flutter_archkit.dart';
import '../models/weather_model.dart';
class WeatherBloc extends Bloc<WeatherEvent, WeatherState> {
WeatherBloc() : super(WeatherInitial()) {
on<FetchWeatherEvent>(_onFetchWeather);
}
@Archkit(
endpoint: '/weather',
method: 'GET',
returnType: WeatherModel,
)
Future<void> _onFetchWeather(
FetchWeatherEvent event,
Emitter<WeatherState> emit, {
required String city,
String? units,
}) async {
// Business logic...
}
}
Step 2: Run Code Generator
# Run code generation on target feature
archkit generate --path lib/features/weather
# Or use shortcuts
archkit g -p lib/features/weather
# Preview changes without modifying files
archkit g -p lib/features/weather --dry-run
6. Multi-Flavor Configuration (archkit flavor) #
Easily configure enterprise-grade multi-environment setups (e.g. dev, staging, prod) for both Android and iOS in seconds.
# Initialize flavor.yaml template
archkit flavor --init
# Validate syntax
archkit flavor --validate
# Generate Android, iOS, Dart, and IDE flavor files
archkit flavor
π Directory Structures #
- ποΈ Clean Architecture Details: doc/clean_architecture.md
- π¨ MVVM Architecture Details: doc/mvvm_architecture.md
- ποΈ MVC Architecture Details: doc/mvc_architecture.md
π Example Application #
A full reference application demonstrating Clean Architecture, MVVM, MVC, Network Layer, Routing, and Flavor configurations is available in the example/ directory.
To run the example app:
cd example
flutter pub get
flutter run
π€ Contributing & Issues #
Contributions, feature suggestions, and bug reports are welcome!
- π Report Issues: GitHub Issue Tracker
- π‘ Source Code: GitHub Repository
π License #
This project is licensed under the MIT License - see the LICENSE file for details.