fbloc CLI
A scaffolding CLI for Flutter projects with feature-first architecture and BLoC/Cubit state management.
Tip: Please use fbloc_cli v2.0.0 or newer β it's stable and errorβfree.
What it does
- Creates a new Flutter app with opinionated structure
- Generates default features:
homeandauth - Scaffolds additional features and views on demand
- Prints concise, user-friendly output with icons
Installation
From pub.flutter-io.cn:
dart pub global activate fbloc_cli
From source (local path):
dart pub get
dart pub global activate --source path .
Ensure your pub cache bin is on PATH so fbloc is available.
Usage
Create a new project (recommended)
fbloc create project my_app
or the shorthand:
fbloc create my_app
Project creation will:
- Prompt for configuration (Network, State Management, Navigation, Equatable)
- Create Flutter project structure
- Generate default
homefeature (withhome_screen) and the fullauthfeature - Save preferences in
.cli_config.json
Final output looks like:
π¦ Project "my_app" created successfully!
β¨ Features generated:
π§© home, auth
π Generated folders:
π app/features/home/ (with home_screen)
π app/features/auth/
π app/core/theme/
π app/core/utils/
π app/core/service/
π app/routes/
β‘οΈ Next steps:
β€ cd my_app
β€ flutter pub get
β€ flutter run
Create a new feature
fbloc create feature auth
or
fbloc feature auth
Final output (concise):
β¨ Feature generated: auth
Create a new view
fbloc view login on auth
Final output (concise):
πΌοΈ View generated: login on auth
Configuration
On first project creation, you'll be prompted to configure:
- Network package: http (default) or dio
- State management: bloc (default) or cubit
- Navigation: go_router (default) or navigator
- Equatable: yes (default) or no
Configuration is saved in .cli_config.json and used for all subsequent feature/view generation.
Generated Structure
lib/
βββ app/
βββ features/
β βββ home/
β β βββ bloc/ or cubit/
β β βββ repository/
β β βββ model/
β β βββ view/
β βββ auth/
β βββ bloc/ or cubit/
β βββ repository/
β βββ model/
β βββ view/
βββ core/
β βββ theme/
β βββ utils/
β βββ service/
βββ routes/