π SM CLI β Flutter Clean Architecture Generator
A powerful CLI tool to generate production-ready Flutter projects with clean architecture, multiple state management options, and feature-based structure.
π¦ Installation
dart pub global activate sm_cli
Make sure Dart is in your PATH:
export PATH="$PATH":"$HOME/.pub-cache/bin"
β¨ Features
- β‘ Flutter project initializer with clean architecture
- π§© Feature-based folder structure (Data, Domain, Presentation)
- π Multiple state management β Riverpod, Bloc, GetX, Provider
- π API layer generator (Dio, interceptors, response wrapper)
- π£οΈ GoRouter integration with auto route generation
- π¨ Theme setup (light + dark)
- πΎ Project config auto-saved (no need to specify state management every time)
π Quick Start
# 1. Install
dart pub global activate sm_cli
# 2. Create project
sm init my_app
# 3. Generate feature
sm make feature my_app auth
# 4. Generate API layer
sm make api my_app
# 5. List features
sm list my_app
# 6. Run
cd my_app && flutter run
π Commands
sm init <project_name>
sm init my_app
sm init my_app --riverpod
sm init my_app --bloc
sm init my_app --getx
sm init my_app --provider
sm make feature <project_name> <feature_name>
sm make feature my_app auth
sm make feature my_app home
sm make feature my_app profile
sm make api <project_name>
sm make api my_app
sm list <project_name>
sm list my_app
Prompts:
- Select State Management (Riverpod / Bloc / GetX / Provider)
- Enable GoRouter? (y/n)
- Enable Theme? (y/n)
Or use flags to skip prompts:
sm init my_app --riverpod
sm init my_app --bloc
sm init my_app --getx
sm init my_app --provider
sm make feature <project_name> <feature_name>
Generates a complete feature with clean architecture structure.
sm make feature my_app auth
sm make feature my_app home
sm make feature my_app profile
State management is auto-detected from project config β no need to specify every time.
sm make api <project_name>
Generates a complete API layer using Dio.
sm make api my_app
π Generated Structure
Project Structure
my_app/
βββ lib/
β βββ core/
β β βββ constants/
β β βββ network/
β β β βββ dio_client.dart
β β β βββ api_endpoints.dart
β β β βββ response_wrapper.dart
β β β βββ network_exceptions.dart
β β β βββ interceptors/
β β β βββ logging_interceptor.dart
β β βββ routes/
β β β βββ app_router.dart
β β β βββ app_routes.dart
β β βββ theme/
β β β βββ app_theme.dart
β β βββ utils/
β βββ features/
β β βββ auth/
β βββ shared/
βββ .sm_cli_config
βββ pubspec.yaml
Feature Structure β Riverpod / Provider
auth/
βββ data/
β βββ datasource/
β β βββ auth_remote_datasource.dart
β βββ models/
β β βββ auth_model.dart
β βββ repository/
β βββ auth_repository.dart
β βββ auth_repository_impl.dart
βββ domain/
β βββ entities/
β β βββ auth_entity.dart
β βββ repository/
β β βββ auth_repository.dart
β βββ usecases/
β βββ auth_usecase.dart
βββ presentation/
βββ screens/
β βββ auth_screen.dart
βββ providers/
β βββ auth_provider.dart
βββ widgets/
Feature Structure β Bloc
auth/
βββ presentation/
βββ screens/
β βββ auth_screen.dart
βββ bloc/
β βββ auth_bloc.dart
β βββ auth_event.dart
β βββ auth_state.dart
βββ widgets/
Feature Structure β GetX
auth/
βββ presentation/
βββ screens/
β βββ auth_screen.dart
βββ views/
β βββ auth_view.dart
βββ controllers/
β βββ auth_controller.dart
βββ bindings/
β βββ auth_binding.dart
βββ widgets/
π State Management
| Feature | Riverpod | Bloc | GetX | Provider |
|---|---|---|---|---|
| State file | _provider.dart |
_bloc.dart |
_controller.dart |
_provider.dart |
| Folder | providers/ |
bloc/ |
controllers/ |
providers/ |
| Extra | β | _event, _state |
_binding, _view |
β |
| Package | flutter_riverpod | flutter_bloc | get | provider |
π API Layer
Generated by sm make api:
// dio_client.dart β singleton Dio instance
final client = DioClient().dio;
// api_endpoints.dart β all your endpoints
class ApiEndpoints {
static const baseUrl = "https://api.example.com";
static const login = "/login";
}
π£οΈ Routing
Routes are auto-generated and updated when you run sm make feature:
// app_routes.dart β auto updated
class AppRoutes {
static const home = '/';
static const auth = '/auth'; // auto added by sm make feature
}
// app_router.dart β auto updated
final appRouter = GoRouter(
routes: [
GoRoute(
path: AppRoutes.auth, // auto added by sm make feature
builder: (context, state) => const AuthScreen(),
),
],
);
---
## π¨ Theme
Light and dark theme pre-configured with Material 3:
```dart
MaterialApp.router(
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
routerConfig: appRouter,
);
π All Flags
sm init <name> # Interactive setup
sm init <name> --riverpod # Skip prompt, use Riverpod
sm init <name> --bloc # Skip prompt, use Bloc
sm init <name> --getx # Skip prompt, use GetX
sm init <name> --provider # Skip prompt, use Provider
sm --help # Show help
sm --version # Show version
π Why SM CLI?
| SM CLI | mason | very_good_cli | |
|---|---|---|---|
| Clean Architecture | β | β | β |
| Multiple state mgmt | β | β | β (Bloc only) |
| Auto route update | β | β | β |
| API layer generator | β | β | β |
| Project config | β | β | β |
| Interactive CLI | β | β | β |
π Issues & Feedback
Found a bug or have a suggestion? π Open an issue
π License
MIT License β see LICENSE
Libraries
- commands/init_command
- commands/make_command
- commands/remove_command
- core/theme/app_theme
- generators/api_generator
- generators/feature_generator
- generators/folder_generator
- generators/main_generator
- generators/router_generator
- generators/routes_constant_generator
- generators/theme_generator
- services/config_service
- services/flutter_service
- services/prompt_service
- sm_cli
- SM CLI β Flutter Clean Architecture Generator