flutter_init_cli 1.0.0
flutter_init_cli: ^1.0.0 copied to clipboard
A production-ready, modular, plugin-based Flutter Project Generator CLI that configures theme, architecture, routing, and state management.
Flutter Init CLI 🚀 #
flutter_init_cli is a professional-grade, plugin-based Command Line Interface (CLI) tool designed to scaffold and generate clean, modular, and production-ready Flutter applications in seconds.
By automating boilerplate creation, folder structures, dependency wiring, declarative routing, and environment configurations, this tool saves developers hours of setup time and enforces standard architecture patterns.
Table of Contents 📖 #
- Key Features
- Prerequisites
- Installation
- Step-by-Step Getting Started Guide
- Commands Reference
- Supported Architectures & Generated Folders
- Environment & IDE Configuration
- Troubleshooting & FAQs
Key Features 🌟 #
- Interactive Setup Wizard: A clean, keyboard-interactive command-line interface with arrow-key navigation for selection prompts.
- Multiple Folder Architectures: Choose the right structural layout for your scale:
- Feature-First: Domain-driven directories grouped by feature module (Presentation, Domain, Data).
- Clean Architecture: Strict separation of concerns divided into layers.
- MVC / MVVM / Layer-First: Standard layered formats for traditional architectures.
- Diverse State Management Configurations: Out-of-the-box boilerplate and configuration hooks for:
ProviderRiverpodBLoC/CubitGetXMobX(including automatically runningbuild_runnercode generation)
- Declarative Routing: Boilerplate for standard
Navigatornamed routes orGoRouterdeclarative routing. - Networking & Offline Storage integration: Instant setup for
Dio,HTTP,Hivedatabase,SharedPreferences, andSecureStorage. - Type-Safe Styling & Typography: Type-safe theme setup with primary color seed configs, dark mode triggers, and a clean, custom
AppTextStylesclass utilizing standard Material font weights (w400,w500,w600,w700).
Prerequisites 📋 #
Before installing and using the CLI, ensure the following are installed and configured on your system:
- Flutter SDK (Version 3.10.0 or higher is recommended)
- Ensure the
fluttercommand is working in your terminal.
- Ensure the
- Dart SDK (Bundled automatically with the Flutter SDK)
- Ensure the
dartcommand is accessible.
- Ensure the
- CocoaPods (Required for iOS/macOS build toolchains on macOS)
Installation 📦 #
To activate the CLI globally from the source directory, run:
dart pub global activate --source path .
Adding Pub Executables to your Path: #
If you run flutter_init_cli and receive a command not found error, you must add Dart's global package bin directory to your shell configuration profile (e.g., .zshrc, .bash_profile, or Windows Environment Variables).
-
macOS / Linux: Add the following line to your
~/.zshrcor~/.bashrc:export PATH="$PATH":"$HOME/.pub-cache/bin"Then reload your terminal:
source ~/.zshrc -
Windows: Add
%USERPROFILE%\AppData\Local\Pub\Cache\binto your UserPATHenvironment variables.
Step-by-Step Getting Started Guide 🚀 #
Step 1: Create a New App Boilerplate #
Create a clean directory where you want to store your Flutter starter, navigate there, and run the wizard:
flutter_init_cli create
Follow the interactive prompts:
- Project Name: Enter a valid snake_case Flutter package identifier (e.g.,
my_awesome_app). - UI Theme: Choose between Material 3 or Cupertino.
- Primary Color: Input a HEX color (e.g.,
#6200EE) to seed the theme. - Dark Mode: Enable or disable automatic dark theme configurations.
- Custom Font: Choose whether to register a custom font family (e.g.,
OutfitorInter). (Note: You will need to add the font file to your assets and register it inpubspec.yamlto display it; see Custom Font Asset Setup below). - Architecture Layout: Select between MVC, MVVM, Clean Architecture, Feature-First, or Layer-First.
- State Management: Choose Provider, Riverpod, BLoC, GetX, or MobX.
- Routing Solution: Select standard Navigator named routing or GoRouter declarative routing.
- Networking & Storage Options: Select the packages you want to pull and configure automatically.
The CLI will create the Flutter project, run flutter pub get, configure all dependencies/folders, and run any needed code-generation builders.
Step 2: Generate Feature Screens on the fly #
Navigate into your newly generated project folder:
cd my_awesome_app
To generate a new feature module (e.g., profile screen):
flutter_init_cli generate profile
The CLI reads the project layout configuration stored inside .flutter_init_cli.json and automatically scaffolds the corresponding folder structure (Data, Domain, Presentation) and state management classes matching the project layout!
Commands Reference 🛠️ #
1. create Command #
Scaffolds a new project.
- Usage:
flutter_init_cli create [options] - Options:
-n, --name: The name of the project. If not provided, the interactive wizard will ask for it.-h, --help: Prints usage information for the create command.
2. generate Command (or alias g) #
Scaffolds a feature module or screen inside an existing generated project.
- Usage:
orflutter_init_cli generate <feature_name>flutter_init_cli g <feature_name> - Options:
-h, --help: Prints usage information for the generate command.
Supported Architectures & Generated Folders 📁 #
A. Clean Architecture & Feature-First Layouts #
When you run flutter_init_cli g <feature> inside a feature-based project, the CLI generates the complete Clean Architecture layout:
lib/
└── features/
└── <feature_name>/
├── data/
│ ├── datasources/
│ ├── models/
│ └── repositories/
├── domain/
│ ├── entities/
│ ├── repositories/
│ └── usecases/
└── presentation/
├── <state_folder>/ (e.g., bloc, provider, controller)
├── views/ (contains <feature_name>_view.dart)
└── widgets/
B. MVC / MVVM / Layer-First Layouts #
For traditional layered architectures, views and state files are generated in globally shared directories rather than nested folders:
- Views: Placed under
lib/views/(e.g.,lib/views/profile_view.dart). - State Managers: Placed under
lib/controllers/,lib/viewmodels/, orlib/providers/depending on the choice.
Environment & IDE Configuration 🔒 #
Dotenv Configuration #
Every generated project includes a .env file at the root containing your default API URL config and a .env.example template.
- The
.envfile is automatically added to the project's.gitignoreto prevent secret leakage. - In
main.dart,dotenv.load(fileName: ".env")is pre-configured.
VS Code Integration #
Because macOS and VS Code hide dotfiles (like .env) by default, the CLI generates a .vscode/settings.json file containing:
{
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/node_modules": true
}
}
This configuration forces the VS Code explorer tree to display .env and .env.example so you can edit configurations immediately.
Custom Font Asset Setup #
If you select a custom font family name (for example: Outfit) during the creation wizard, the CLI sets it up as the default fontFamily in your MaterialApp theme and AppTextStyles class.
To make the font render correctly inside the app, you must add the corresponding font asset files to your project and register them in pubspec.yaml:
- Download the font files (e.g.,
Outfit-Regular.ttf,Outfit-Medium.ttf,Outfit-SemiBold.ttf,Outfit-Bold.ttf) from Google Fonts. - Create a folder in your project root at
assets/fonts/and place the.ttffiles inside it. - Open
pubspec.yamland register the font files under theflutter:block:flutter: fonts: - family: Outfit fonts: - asset: assets/fonts/Outfit-Regular.ttf weight: 400 - asset: assets/fonts/Outfit-Medium.ttf weight: 500 - asset: assets/fonts/Outfit-SemiBold.ttf weight: 600 - asset: assets/fonts/Outfit-Bold.ttf weight: 700
Troubleshooting & FAQs ❓ #
Q: I made changes to the CLI source code, but the changes aren't appearing when I run flutter_init_cli. #
A: Since globally activated path packages run from a compiled snapshot, Dart caches the executable. When you modify the source files in lib/ or bin/, you must update the snapshot by re-running:
dart pub global activate --source path .
Q: I get a compilation error inside the generated project's router. #
A: Ensure that all generated dependencies are fully resolved. Run:
flutter pub get
If using packages that require code generation (like MobX or Riverpod code generation), run:
dart run build_runner build --delete-conflicting-outputs
Q: Does the generator support Cupertino themes? #
A: Yes! Selecting the Cupertino theme in the wizard automatically generates a theme configuration class in lib/core/theme/app_theme.dart returning a CupertinoThemeData and wraps the app in a CupertinoApp (or GetCupertinoApp).