🚀 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. Create new project
sm init my_app

# 2. Go to project
cd my_app

# 3. Generate a feature
sm make feature my_app auth

# 4. Generate API layer
sm make api my_app

# 5. Run
flutter run

📋 Commands

sm init <project_name>

Creates a new Flutter project with clean architecture setup.

sm init 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