A powerful command-line tool to bootstrap and manage scalable, feature-first Flutter projects with Clean Architecture principles.
Flutter Engine CLI is a CLI tool that helps you create and maintain Flutter projects following Clean Architecture patterns. It automatically generates:
- Clean Architecture folder structure with proper separation of concerns
- Feature-based organization for scalable codebases
- State management integration (BLoC, Riverpod, or basic)
- Network layer setup with Dio
- Navigation setup with Go Router
- Local storage with Hive
- Dependency injection with GetIt
- Error handling and failure management
- Theme and styling infrastructure
- Rust FFI integration for high-performance JSON and image processing (optional)
- Flutter SDK (>=3.0.0)
- Dart SDK (>=3.0.0)
dart pub global activate flutter_engine_cliflutter create my_awesome_app
cd my_awesome_appflutter_engine_cli initThe tool will guide you through an interactive setup process:
π Initializing project "my_awesome_app" with Clean Architecture...
Select state management solution:
1. BLoC
2. Riverpod
3. None (use basic state management)
Enter your choice (1-3): 2
Do you want to add Dio for advanced network requests? (y/n): y
Do you want to add go_router for navigation? (y/n): y
Do you want to add Hive for local storage? (y/n): y
Do you want to add Rust FFI for high-performance JSON and image processing? (y/n): y
π¦ Adding required dependencies...
β
Created folder: lib/core/common
β
Created folder: lib/core/common/widgets
β
Created folder: lib/core/config
β
Created folder: lib/core/constants
β
Created folder: lib/core/di
β
Created folder: lib/core/error
β
Created folder: lib/core/network
β
Created folder: lib/core/storage
β
Created folder: lib/core/theme
β
Created folder: lib/core/utils
β
Created folder: lib/features
π Adding initial "home" feature...
π Project initialized successfully!
Run `flutter pub get` to install dependencies.
flutter pub get# Interactive mode - the tool will guide you through the setup
flutter_engine_cli add
# Or use command-line arguments
flutter_engine_cli add --name user_profile --state riverpod --with-g-routes
flutter_engine_cli add --name product_catalog --state bloc --with-g-routes
flutter_engine_cli add --name settingsFlutter Engine CLI follows Clean Architecture principles with a feature-first approach:
lib/
βββ core/ # Shared infrastructure
β βββ common/ # Common utilities and widgets
β βββ config/ # App configuration
β βββ constants/ # App constants
β βββ di/ # Dependency injection
β βββ error/ # Error handling
β βββ network/ # Network layer
β βββ storage/ # Local storage
β βββ theme/ # App theming
β βββ utils/ # Utility functions
β βββ ffi/ # Rust FFI integration (if enabled)
βββ features/ # Feature modules
β βββ home/ # Home feature
β β βββ data/ # Data layer
β β β βββ datasources/ # Remote/local data sources
β β β βββ models/ # Data models
β β β βββ repositories/ # Repository implementations
β β βββ domain/ # Domain layer
β β β βββ entities/ # Business entities
β β β βββ repositories/ # Repository interfaces
β β β βββ usecases/ # Business logic
β β βββ presentation/ # Presentation layer
β β βββ pages/ # UI pages
β β βββ state/ # State management
β β βββ widgets/ # Feature-specific widgets
β βββ [other_features]/ # Other features
βββ main.dart # App entry point
rust/ # Rust FFI project (if enabled)
βββ Cargo.toml # Rust project configuration
βββ build.sh # Build script (Unix)
βββ build.bat # Build script (Windows)
βββ Makefile # Makefile for building
βββ README.md # Rust FFI documentation
βββ QUICK_START.md # Quick start guide
βββ src/ # Rust source code
βββ lib.rs # Main library file
βββ ffi.rs # FFI bindings
βββ json_processing.rs # JSON processing logic
βββ image_processing.rs # Image processing logic
βββ cache.rs # Caching implementation
Flutter Engine CLI provides an intuitive interactive command-line interface that guides you through the setup process. Both commands support interactive prompts when arguments are not provided.
- Guided Setup: Step-by-step prompts for configuration options
- Input Validation: Real-time validation with helpful error messages
- Default Values: Sensible defaults for quick setup
- Flexible Usage: Use command-line arguments for automation or interactive prompts for exploration
Initializes a new Flutter project with Clean Architecture structure.
Interactive Options:
- State Management: Choose between BLoC, Riverpod, or basic state management
- Network Layer: Add Dio for HTTP requests
- Navigation: Add Go Router for navigation
- Local Storage: Add Hive for local data persistence
- Rust FFI: Add Rust FFI for high-performance JSON and image processing
What it creates:
- Complete folder structure following Clean Architecture
- Core infrastructure files (DI, error handling, theming, etc.)
- Initial "home" feature
- Dependencies in
pubspec.yaml - Configured
main.dart
Adds a new feature to your project with complete Clean Architecture structure. The command supports both interactive prompts and command-line arguments.
Options:
--nameor-n: Feature name in snake_case (optional - will prompt if not provided)--state: State management choice (riverpod,bloc,none)--with-g-routes: Generate Go Router routes for the feature
Interactive Mode: If you don't provide arguments, the tool will guide you through an interactive setup:
flutter_engine_cli addInteractive Process:
Enter the name of the feature in snake_case (e.g., "user_profile"): auth
Choose state management for this feature (riverpod/bloc/none) [none]: riverpod
Do you want to generate a route for this feature using go_router? (y/n) [n]: y
β
Feature "auth" added successfully!
Command-Line Examples:
# Basic feature without state management
flutter_engine_cli add --name user_profile
# Feature with Riverpod state management
flutter_engine_cli add --name product_catalog --state riverpod
# Feature with BLoC state management and routing
flutter_engine_cli add --name checkout --state bloc --with-g-routes
# Interactive mode (no arguments)
flutter_engine_cli addimport 'package:get_it/get_it.dart';
import 'package:dio/dio.dart';
final sl = GetIt.instance;
Future<void> init() async {
// External Dependencies
sl.registerLazySingleton<Dio>(() => Dio());
// Core
sl.registerLazySingleton<ApiClient>(() => ApiClientImpl(dio: sl()));
// Features
// Register your feature dependencies here
}import 'package:equatable/equatable.dart';
abstract class Failure extends Equatable {
const Failure([List properties = const <dynamic>[]]);
@override
List<Object> get props => [];
}
class ServerFailure extends Failure {}
class CacheFailure extends Failure {}import 'dart:ffi';
import 'package:ffi/ffi.dart';
class RustFFI {
static Future<RustFFI> getInstance() async { ... }
// High-performance JSON operations
String jsonDecode(String json);
String jsonEncode(String data);
// Image processing
int processImage(String imagePath, String outputPath, int width, int height, int quality);
String? getOrCacheImage(String imagePath, String cacheKey, int width, int height, int quality);
}class HybridParser<T, R> {
final String json;
final ParseFunction<R> parseFunction;
// Parse JSON using Rust FFI in an isolate for non-blocking performance
Future<R> parse() async { ... }
}Each feature follows the same pattern:
- Entities: Business objects
- Repositories: Abstract interfaces
- Use Cases: Business logic
- Models: Data transfer objects
- Data Sources: Remote/local data access
- Repository Implementations: Concrete implementations
- Pages: UI screens
- State Management: BLoC/Riverpod providers
- Widgets: Reusable UI components
- Uses
flutter_riverpodpackage - Generates provider files for each feature
- Integrates with dependency injection
- Uses
flutter_blocandblocpackages - Generates BLoC, Event, and State files
- Follows BLoC pattern conventions
- No additional state management
- Uses basic
setStateorChangeNotifier
When Dio is selected:
- Configures Dio client with interceptors
- Creates API client abstraction
- Sets up environment configuration
- Generates API endpoints structure
When Go Router is selected:
- Creates router configuration
- Generates route definitions
- Integrates with feature pages
When Hive is selected:
- Configures Hive for local storage
- Creates storage service abstraction
- Sets up data persistence utilities
When Rust FFI is selected:
- Creates complete Rust project structure with Cargo.toml
- Generates Rust FFI bindings for JSON and image processing
- Sets up hybrid parser that uses Rust in isolates for non-blocking performance
- Creates image service with caching capabilities
- Provides cross-platform build scripts (build.sh, build.bat, Makefile)
- Generates comprehensive documentation (README.md, QUICK_START.md)
Features:
- High-performance JSON processing: Rust-powered JSON parsing and encoding
- Image processing: Resize, compress, and cache images efficiently
- Image caching: Smart caching system for processed images
- Isolate-based execution: Non-blocking operations using Dart isolates
Requirements:
- Rust toolchain (install from https://rustup.rs/)
- Platform-specific build tools (varies by OS)
Setup Steps:
- Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Build the library:
- Windows:
cd rust && build.bat - macOS/Linux:
cd rust && ./build.sh
- Windows:
- Copy the built library to your platform-specific location
- See
rust/README.mdfor detailed platform-specific instructions
The tool automatically adds these dependencies based on your choices:
get_it: Dependency injectiondartz: Functional programming utilitiesequatable: Value equalityconnectivity_plus: Network connectivity
flutter_riverpod: Riverpod state managementflutter_bloc&bloc: BLoC state management
dio: HTTP client
go_router: Declarative routing
hive&hive_flutter: Local storage
ffi: Foreign Function Interface for native code integrationcrypto: Cryptographic hashing for cache keys
hive_generator: Hive code generationbuild_runner: Code generation runner
- One feature per command: Use
flutter_engine_cli addfor each feature - Consistent naming: Use snake_case for feature names
- State management: Choose the same pattern across features for consistency
- Routing: Use
--with-g-routesfor features that need navigation
- Keep features independent: Each feature should be self-contained
- Use dependency injection: Register feature dependencies in the injector
- Follow naming conventions: Use the generated naming patterns
- Extend generated code: Build upon the scaffold, don't replace it
- Update dependencies: Regularly update Flutter and package versions
- Review generated code: Customize templates as needed for your project
- Document features: Add README files to complex features
- Test thoroughly: Add unit and widget tests for each feature
- Ensure you're running commands from the Flutter project root
- Verify the project is a valid Flutter project
- Check your Flutter installation:
flutter doctor - Verify internet connection for dependency downloads
- Try running
flutter pub getmanually
- Use underscores instead of hyphens or spaces
- Example:
user_profileβ ,user-profileβ
- Ensure Rust is installed:
rustc --version - Check that build scripts are executable:
chmod +x rust/build.sh(Unix) - Verify platform-specific build tools are installed
- Review
rust/README.mdfor platform-specific requirements - For Android: Ensure NDK is properly configured
- For iOS: Ensure Xcode command-line tools are installed
- Check the generated code structure
- Review the template files in
lib/src/templates/ - Verify your Flutter and Dart versions
- Check the project's
pubspec.yamlfor dependency conflicts - For Rust FFI issues, check
rust/README.mdand ensure Rust is properly installed
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Rust FFI Integration: Added optional Rust FFI support for high-performance JSON and image processing
- Hybrid Parser: Implemented isolate-based hybrid parser for non-blocking JSON operations
- Image Service: Added image processing and caching service with Rust backend
- Cross-platform Build Scripts: Generated build scripts for Windows, macOS, and Linux
- Comprehensive Documentation: Auto-generated Rust project documentation
- Added comprehensive error handling
- Improved interactive prompts
- Enhanced template generation
- Added support for multiple state management options
- Initial release with basic init and add feature commands
- Clean Architecture template generation
- State management integration
Happy coding! π
Built with β€οΈ for the Flutter community.