Flutter ArchKit
A comprehensive Flutter Architecture CLI generator and multi-flavor configuration tool. flutter_archkit automates scaffolding Flutter projects with Clean, MVVM, or MVC architecture, state management (Bloc, Cubit, Riverpod, Provider, GetX), modular feature generators, routing setup, network layer generation, and multi-flavor environment configurations.
Features
- 🏗️ Interactive Project Generator (
archkit create): Scaffolds complete Flutter apps with interactive CLI prompts for Architecture, State Management, Organization ID, and Target Platforms. - ⚡ Feature Module Generator (
archkit feature <name>/archkit -f <name>): Instantly generates feature modules (auth,profile,home, etc.) matching your project's architecture. - 🛣️ Route System Setup (
archkit route/archkit r): Scaffolds routing configurations with support for Navigator 1.0, Navigator 2.0, Go Router (with optionalStatefulShellRoutebottom navigation), Auto Route, and GetX Routing. - 🌐 Network Layer Generator (
archkit network/archkit n): Scaffolds production-ready Dio network layer with genericApiResponse<T>, customApiException, typed interfaces, logger/auth interceptors, and utilitytypedefs. - 🔄 Smart Metadata Auto-Detection: Stores selected project configuration in
.metadataso features and routes integrate seamlessly without requiring command flags. - 📂 Modular Template Engine: Clean templates for Clean Architecture (data, domain, presentation, di), MVVM (models, services, viewmodels, views), and MVC (models, controllers, views).
- 🤖 Android Flavor Setup: Automatically configures
productFlavorsandapplicationIdinandroid/app/flavor.gradle.ktsand links withbuild.gradle.kts. - 🍎 iOS Flavor Setup: Generates flavor
.xcconfigfiles, CocoaPods target dependencies (#include? Pods-Runner), shared.xcschemeschemes, patchesInfo.plist, updates Xcodeproject.pbxprojbuild configurations, and setsIPHONEOS_DEPLOYMENT_TARGET = 16.0. - ⚙️ Dart ServerConfig: Generates strongly-typed
lib/core/config/server_config.dartruntime environment configurations. - 💻 IDE Support: Automatically writes
.vscode/launch.jsonfor VS Code and.run/<flavor>.run.xmlrun configurations for Android Studio / IntelliJ IDEA.
Installation
Activate flutter_archkit globally via Pub:
dart pub global activate flutter_archkit
Or add it to your project pubspec.yaml under dev_dependencies:
dev_dependencies:
flutter_archkit: ^0.1.0
Usage Guide
1. Creating a New Flutter Project (archkit create)
Run the interactive project creation wizard:
archkit create my_app
Interactive Prompts:
- Select Architecture:
Clean|MVVM|MVC - Select State Management:
Bloc|Cubit|Riverpod|Provider|GetX - Organization Identifier: e.g.,
com.example - Platforms:
Android,iOS,Web,Windows,macOS,Linux
Or pass parameters via command flags:
archkit create my_app --org com.example --architecture Clean --state-management Bloc --platforms android,ios
2. Scaffolding a Feature Module (archkit feature <name> / archkit -f <name>)
Inside any project created with archkit, run:
archkit feature auth
or use the shortcut:
archkit -f auth
archkit auto-detects your project's architecture and state management from .metadata and generates the feature module matching your established code structure!
3. Setting Up Route System (archkit route / archkit r)
Set up a robust routing system tailored to your preferred router package:
archkit route
or use the alias:
archkit r
Interactive Prompts:
- Select Route System:
Navigator 1.0(Standard Flutter MaterialPageRoute)Navigator 2.0(Declarative RouterDelegate & RouteInformationParser)Go Router(Supports--shellflag forStatefulShellRoutebottom navigation)Auto Route(Strongly-typed code-generated routes)GetX Routing(GetMaterialApp & GetPage routes)
CLI Command Flags:
# Non-interactive Go Router setup with Stateful Shell Navigation
archkit route --type "Go Router" --shell
# Auto Route setup
archkit route -t auto_route
# GetX Routing setup
archkit route -t getx
Note: Running archkit route automatically updates pubspec.yaml with the required router dependencies (e.g. go_router, auto_route, get) and persists the router choice in .metadata.
4. Scaffolding Network Layer (archkit network / archkit n)
Generate a production-grade Dio HTTP client architecture:
archkit network
or use the alias:
archkit n
CLI Command Flags:
# Specify target directory path
archkit network --path ./my_project
# Force overwrite existing network files
archkit network --override
Note: Running archkit network automatically adds dio: ^5.4.3 to your project's pubspec.yaml.
5. Multi-Flavor Setup (setup_flavor)
Generate a sample flavor.yaml automatically:
dart run flutter_archkit:setup_flavor --init
Or create flavor.yaml manually in your project root:
flavors:
dev:
app:
name: "Example Dev"
baseUrl: "https://dev-api.example.com"
android:
applicationId: "com.example.app.dev"
ios:
bundleId: "com.example.app.dev"
prod:
app:
name: "Example"
baseUrl: "https://api.example.com"
android:
applicationId: "com.example.app"
ios:
bundleId: "com.example.app"
Validate your configuration:
dart run flutter_archkit:setup_flavor --validate
Execute the multi-flavor code generator:
dart run flutter_archkit:setup_flavor
Generated Architecture Layouts
Clean Architecture (lib/features/auth/)
lib/features/auth/
├── data/
│ ├── data_sources/
│ │ ├── auth_remote_datasource.dart
│ │ └── auth_remote_datasource_impl.dart
│ ├── models/
│ │ └── auth_model.dart
│ └── repositories/
│ └── auth_repository_impl.dart
├── di/
│ ├── auth_di.dart
│ └── auth_di.config.dart
├── domain/
│ ├── repositories/
│ │ └── auth_repository.dart
│ └── usecases/
│ └── auth_usecase.dart
└── presentation/
├── bloc/ (or cubit / riverpod / provider / controllers)
│ ├── auth_bloc.dart
│ ├── auth_event.dart
│ └── auth_state.dart
└── page/
└── auth_page.dart
Route System Structure (lib/core/router/)
lib/core/router/
├── app_router.dart # Central router definition (GoRouter / RouterDelegate / AppPages)
├── app_routes.dart # Route name string constants
├── route_functions.dart # Navigation helper utilities (push, pop, clearAndGo)
└── bottom_shell_route.dart # StatefulShellRoute bottom navbar shell widget (Go Router)
Network Layer Structure (lib/core/)
lib/core/
├── network/
│ ├── api_exception.dart # Typed network exception handling
│ ├── api_interface.dart # Abstract API client contract interface
│ ├── dio.dart # Configured Dio HTTP client factory instance
│ ├── dio_network.dart # Concrete Dio HTTP request handler
│ ├── dio_services.dart # Base network service class
│ └── interceptors/
│ ├── api_interceptor.dart # Auth token & header interceptor
│ └── logging.dart # HTTP request/response logger interceptor
└── util/
├── api_response.dart # Generic ApiResponse<T> state wrapper
└── typedefs.dart # Utility Dart typedefs (JSON, Callbacks)
MVVM Architecture (lib/)
lib/
├── models/auth_model.dart
├── services/auth_service.dart
├── viewmodels/auth_provider.dart (or auth_viewmodel.dart / auth_bloc.dart / auth_controller.dart)
└── views/auth_view.dart
MVC Architecture (lib/)
lib/
├── models/auth_model.dart
├── controllers/auth_controller.dart
└── views/auth_view.dart
License
This project is licensed under the MIT License - see the LICENSE file for details.