flutter_blueprint 0.2.0-dev.2
flutter_blueprint: ^0.2.0-dev.2 copied to clipboard
Smart Flutter app scaffolding CLI with architecture, theming, routing, and environment handling built-in.
๐ฏ flutter_blueprint #
Enterprise-grade Flutter app scaffolding CLI โ generates production-ready Flutter projects with 43+ professional files, complete architecture, authentication patterns, error handling, storage layers, and reusable widgets. Stop wasting hours on boilerplate โ start building features from day one.
๐ Why flutter_blueprint? #
| Problem | Traditional Approach | flutter_blueprint Solution |
|---|---|---|
flutter create gives bare bones |
Hours of manual setup | 43+ files with pro patterns instantly |
| GitHub templates are opinionated & bloated | Copy-paste, delete unused code | Modular generation - only what you need |
| No professional error handling | Build it yourself | Custom exceptions + Failures out of the box |
| Basic HTTP setup missing interceptors | Add Dio, configure manually | Auth, Retry, Logger interceptors included |
| No reusable widgets | Create from scratch | Loading, Error, Empty states ready to use |
| Form validation boilerplate | Write validators each time | Email, password, phone validators built-in |
| Storage layer missing | Mix SharedPrefs everywhere | LocalStorage + SecureStorage wrappers |
| No proper logging | print() statements everywhere | Professional Logger with levels |
flutter_blueprint is not just a template โ it's a smart code generator that creates production-grade architecture tailored to your choices.
โจ Features #
Core Features #
| Feature | Description | Generated Files |
|---|---|---|
| โก One-command setup | flutter_blueprint init my_app |
42-43 files in seconds |
| ๐งฑ Clean architecture | Separation of concerns (core/, features/, app/) | Professional folder structure |
| ๐ฏ State management | Provider OR Riverpod (Bloc coming soon) | Choose your preferred pattern |
| ๐จ Theming system | Material 3 with custom colors & typography | AppTheme, AppColors, Typography |
| ๐ Internationalization | ARB files + intl config ready | en.arb, hi.arb, localization |
| ๐ ๏ธ Environment config | Dev/Stage/Prod with .env support | EnvLoader + .env.example |
| ๐งญ Professional routing | Route names, guards, centralized navigation | AppRouter, RouteGuard, Routes |
Professional Add-ons (What Makes It Pro) #
| Feature | What You Get |
|---|---|
| ๏ฟฝ Production API Client | Dio + Auth/Retry/Logger interceptors + Generic methods (GET/POST/PUT/DELETE) |
| ๐จ Error Handling System | 9 custom exception classes + Failures for clean architecture |
| ๐ Professional Logger | AppLogger with debug/info/warning/error/success levels |
| โ Form Validators | Email, password, phone, required, minLength, maxLength, numeric |
| ๐พ Storage Layers | LocalStorage (SharedPreferences wrapper) + SecureStorage (tokens) |
| ๏ฟฝ Reusable Widgets | LoadingIndicator, ErrorView, EmptyState, CustomButton, CustomTextField |
| ๐ Network Monitoring | NetworkInfo with connectivity checks |
| ๏ฟฝ Extensions & Utils | String, DateTime, Context extensions + Constants |
| ๐งช Professional Tests | Validator tests, test helpers, widget tests |
| ๐ Smart File Organization | Constants (endpoints, app), Errors, Network, Utils, Widgets |
๐ฆ Installation #
Global Activation (Recommended) #
dart pub global activate flutter_blueprint
Then use it anywhere:
flutter_blueprint init my_app
Local Execution #
dart run flutter_blueprint init my_app
๐ฌ Quick Start #
โจ Interactive Wizard Mode (Recommended) #
Just run without arguments for a beautiful guided experience:
flutter_blueprint init
What happens:
๐ฏ Welcome to flutter_blueprint!
Let's create your Flutter app with professional architecture.
โ ๐ฑ App name ยท my_awesome_app
โ ๐ฏ Choose state management ยท provider
โข Provider (ChangeNotifier, easy to learn)
โข Riverpod (Compile-time safe, better testability) โ NEW!
โข Bloc (Event-driven, coming soon)
[Use โโ arrow keys, Enter to select]
โ โจ Select features to include (use space to select, enter to confirm)
โ Theme system (Light/Dark modes)
โ Localization (i18n support)
โ Environment config (.env)
โ API client (Dio + interceptors)
โ Test scaffolding
๐ Configuration Summary:
App name: my_awesome_app
State management: provider
Theme: โ
Localization: โ
Environment: โ
API client: โ
Tests: โ
โ ๐ Ready to generate your app? ยท yes
๐ Generating project structure...
โ
Generated 43 files successfully!
Features:
- ๐จ Beautiful UI with emojis and colors
- โจ๏ธ Arrow key navigation for selections
- โ๏ธ Multi-select checkboxes for features (spacebar to toggle)
- โ Smart validation (prevents reserved words, invalid names)
- ๐ Configuration preview before generation
โก Quick Mode (For Experienced Users) #
Skip the wizard by providing the app name:
flutter_blueprint init my_app
Add flags for full control:
# Provider template (classic ChangeNotifier pattern)
flutter_blueprint init my_app \
--state provider \
--theme \
--env \
--api \
--tests
# Riverpod template (compile-time safe with StateNotifier)
flutter_blueprint init my_app \
--state riverpod \
--theme \
--env \
--api \
--tests
--no-localization
Hybrid Mode (Mix Both) #
flutter_blueprint init my_app --state riverpod
# Prompts for remaining options
๐ฏ State Management Templates #
flutter_blueprint supports multiple state management patterns โ choose the one that fits your team and project best!
๐ Comparison Table #
| Feature | Provider ๐ข | Riverpod ๐ฆ | Bloc ๐ฃ (Coming Soon) |
|---|---|---|---|
| Package | provider: ^6.1.2 |
flutter_riverpod: ^2.5.1 |
flutter_bloc: ^8.1.0 |
| Learning Curve | Easy - ChangeNotifier pattern | Medium - New concepts | Steep - Event-driven architecture |
| Compile-Time Safety | โ Runtime errors possible | โ Catch errors at compile time | โ Strong typing |
| Testability | Good - MockNotifier needed | Excellent - ProviderContainer | Excellent - Easy to mock |
| State Class | ChangeNotifier |
StateNotifier<State> |
Cubit<State> or Bloc<E, S> |
| UI Update | notifyListeners() |
state = state.copyWith(...) |
emit(newState) |
| Widget Pattern | Consumer<T> / Provider.of |
ConsumerWidget + ref.watch() |
BlocBuilder / BlocConsumer |
| Dependency Injection | MultiProvider wrapper |
ProviderScope + global providers |
BlocProvider tree |
| Automatic Disposal | Manual dispose() required |
โ Automatic | โ Automatic |
| Generated Files | 43 files | 42 files | TBD |
| Best For | Small-medium apps, rapid prototyping | Large apps, enterprise, strong teams | Complex state, event-driven logic |
๐ข Provider Template #
When to use: You want simplicity, familiarity, and quick onboarding for new Flutter developers.
Example State Management:
// home_provider.dart
class HomeProvider extends ChangeNotifier {
bool _isLoading = false;
int _counter = 0;
void incrementCounter() {
_counter++;
notifyListeners(); // Manual notification
}
}
// home_content.dart
Consumer<HomeProvider>(
builder: (context, provider, child) {
return Text('Counter: ${provider.counter}');
},
)
๐ฆ Riverpod Template (NEW!) #
When to use: You want compile-time safety, better testability, and you're building a large-scale app.
Example State Management:
// home_provider.dart
class HomeState {
final bool isLoading;
final int counter;
HomeState({required this.isLoading, required this.counter});
HomeState copyWith({bool? isLoading, int? counter}) {
return HomeState(
isLoading: isLoading ?? this.isLoading,
counter: counter ?? this.counter,
);
}
}
class HomeNotifier extends StateNotifier<HomeState> {
HomeNotifier() : super(HomeState(isLoading: false, counter: 0));
void incrementCounter() {
state = state.copyWith(counter: state.counter + 1); // Immutable update
}
}
final homeProvider = StateNotifierProvider<HomeNotifier, HomeState>((ref) {
return HomeNotifier();
});
// home_content.dart
class HomeContent extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final homeState = ref.watch(homeProvider); // Auto-rebuild on changes
return Column(
children: [
Text('Counter: ${homeState.counter}'),
ElevatedButton(
onPressed: () => ref.read(homeProvider.notifier).incrementCounter(),
child: Text('Increment'),
),
],
);
}
}
Riverpod Benefits:
- โ No BuildContext needed - access providers anywhere
- โ Compile-time errors - typos caught immediately
- โ Immutable state - easier debugging with state history
- โ Auto-disposal - no memory leaks
- โ
Better testing - use
ProviderContainerfor isolated tests - โ Family & AutoDispose modifiers for advanced use cases
๐ฃ Bloc Template (Coming Soon!) #
When to use: You need event-driven architecture, complex business logic, or team is familiar with BLoC pattern.
Stay tuned for Bloc support!
๐งฉ Generated Project Structure (43+ Files!) #
my_app/
โโโ lib/
โ โโโ main.dart # App entry point
โ โโโ app/
โ โ โโโ app.dart # Root app widget with providers
โ โโโ core/
โ โ โโโ api/ # ๐ Network layer
โ โ โ โโโ api_client.dart # Dio client with GET/POST/PUT/DELETE
โ โ โ โโโ api_response.dart # Generic response wrapper
โ โ โ โโโ interceptors/
โ โ โ โโโ auth_interceptor.dart # Auto-add auth tokens
โ โ โ โโโ retry_interceptor.dart # Auto-retry failed requests
โ โ โ โโโ logger_interceptor.dart # Log all API calls
โ โ โโโ config/
โ โ โ โโโ app_config.dart # ๐๏ธ App configuration
โ โ โ โโโ env_loader.dart # Dev/Stage/Prod environments
โ โ โโโ constants/
โ โ โ โโโ app_constants.dart # ๐ Timeouts, storage keys, pagination
โ โ โ โโโ api_endpoints.dart # Centralized API routes
โ โ โโโ errors/
โ โ โ โโโ exceptions.dart # ๐จ 9 custom exception types
โ โ โ โโโ failures.dart # Clean architecture failures
โ โ โโโ network/
โ โ โ โโโ network_info.dart # ๐ก Connectivity monitoring
โ โ โโโ routing/
โ โ โ โโโ app_router.dart # ๐งญ Route management
โ โ โ โโโ route_guard.dart # Auth guards
โ โ โ โโโ route_names.dart # Centralized route constants
โ โ โโโ storage/
โ โ โ โโโ local_storage.dart # ๐พ SharedPreferences wrapper
โ โ โ โโโ secure_storage.dart # Secure token storage
โ โ โโโ theme/
โ โ โ โโโ app_theme.dart # ๐จ Light/Dark themes
โ โ โ โโโ app_colors.dart # Color palette
โ โ โ โโโ typography.dart # Text styles
โ โ โโโ utils/
โ โ โ โโโ logger.dart # ๐ Pro logger (debug/info/warn/error)
โ โ โ โโโ validators.dart # Form validators (email/phone/etc)
โ โ โ โโโ extensions.dart # String/DateTime/Context extensions
โ โ โโโ widgets/ # ๐งฉ Reusable UI components
โ โ โโโ loading_indicator.dart # Loading spinner
โ โ โโโ error_view.dart # Error display with retry
โ โ โโโ empty_state.dart # Empty list placeholder
โ โ โโโ custom_button.dart # Button with loading state
โ โ โโโ custom_text_field.dart # Styled text input
โ โโโ features/
โ โโโ home/ # ๐ Sample feature (clean architecture)
โ โโโ presentation/
โ โโโ pages/
โ โ โโโ home_page.dart # Home screen
โ โโโ providers/
โ โ โโโ home_provider.dart # State management
โ โโโ widgets/
โ โโโ home_content.dart # Home UI components
โโโ assets/
โ โโโ l10n/
โ โโโ en.arb # ๐ English translations
โ โโโ hi.arb # Hindi translations
โโโ test/
โ โโโ widget_test.dart # ๐งช Sample widget test
โ โโโ core/
โ โ โโโ utils/
โ โ โโโ validators_test.dart # Validator unit tests
โ โโโ helpers/
โ โโโ test_helpers.dart # Test utilities
โโโ .env.example # ๐ Environment variables template
โโโ blueprint.yaml # ๐ Project metadata
โโโ pubspec.yaml # ๐ฆ Dependencies
File Count by Feature Set:
- Minimal (no optional features): 19 files
- Full Stack (all features enabled): 43 files ๐
๐ง Architecture Principles #
Clean Separation of Concerns #
core/: Shared infrastructure (config, theme, routing, API)features/: Business logic organized by featureapp/: Root app configuration and providers
Dependency Injection Ready #
Uses Provider for service location:
Provider<AppConfig>(create: (_) => AppConfig.load()),
Provider<ApiClient>(create: (context) => ApiClient(context.read<AppConfig>())),
Type-Safe Configuration #
class AppConfig {
final String appTitle;
final String environment;
final String apiBaseUrl;
// ...
}
๐ ๏ธ CLI Commands #
init - Create New Project #
flutter_blueprint init <app_name> [options]
Options:
| Flag | Description | Default |
|---|---|---|
--state <choice> |
State management (provider/riverpod/bloc) | Interactive prompt |
--theme |
Include theme scaffolding | Interactive prompt |
--localization |
Include l10n setup | Interactive prompt |
--env |
Include environment config | Interactive prompt |
--api |
Include API client | Interactive prompt |
--tests |
Include test scaffolding | Interactive prompt |
-h, --help |
Show help | - |
-v, --version |
Show version | - |
add feature - Incremental feature generation (killer feature) #
Add a new feature to an existing project without touching the rest of your app. The command scaffolds clean-architecture folders (data/domain/presentation), generates state-management boilerplate that matches the project's blueprint.yaml (Provider, Riverpod or BLoC), and injects a new route into app_router.dart.
Usage:
# Full feature with all layers
flutter_blueprint add feature <feature_name>
# Only presentation layer
flutter_blueprint add feature settings --presentation --no-data --no-domain
# Add feature with remote API integration
flutter_blueprint add feature products --api
Flags:
| Flag | Description |
|---|---|
--data / --no-data |
Generate data layer (models, data sources, repository) |
--domain / --no-domain |
Generate domain layer (entities, repository contract, use cases) |
--presentation / --no-presentation |
Generate presentation layer (pages, widgets, state) |
--api |
Include remote data source (Dio) in the data layer |
Behavior & notes:
- The command must be run from the root of a previously generated flutter_blueprint project (it reads
blueprint.yaml). - It detects the project's state-management setting from
blueprint.yamland emits matching files for Provider, Riverpod, or Bloc. - If
app_router.dartexists, the generator will add the page import, a route constant toRouteNames, and acasein the router switch to return the new page. - The generator is idempotent for route insertion: it will not duplicate imports or constants if they already exist.
- For Riverpod/Bloc the generated state files follow the project's Dart version (uses sealed classes / StateNotifier / Bloc patterns as appropriate).
Examples:
# Generate a full "auth" feature using the project's state-management
flutter_blueprint add feature auth
# Generate only presentation for "settings"
flutter_blueprint add feature settings --presentation --no-data --no-domain
# Generate products feature and include remote API data source
flutter_blueprint add feature products --api
๐ blueprint.yaml #
Every generated project includes a blueprint.yaml manifest:
version: 1
app_name: my_app
platform: mobile
state_management: provider
features:
api: true
env: true
localization: false
tests: true
theme: true
Future Use: This enables regeneration, upgrades, and feature addition.
๐ฏ Target Audience #
- Junior developers: who don't yet know how to structure a real project
- Indie devs: who want to spin up production-ready apps quickly
- Small teams: who want standardization without heavy frameworks
๐ง Roadmap #
Phase 1: MVP โ (Current) #
- โ CLI tool setup
- โ Basic project generator
- โ Provider template
- โ Theme + routing boilerplate
Phase 2: Multi-Template Support #
- โ Riverpod template
- โ Bloc template
- โ Localization integration
- โ API client scaffolding
Phase 3: Feature Generation #
- โ
flutter_blueprint add feature <name> - โ Interactive upgrades via
blueprint.yaml - โ Unit + widget test templates
Phase 4: Advanced Features #
- โ Plugin ecosystem (auth, firebase, analytics)
- โ GitHub Actions CI scaffold
- โ Web/desktop platform support
- โ Blueprint dashboard (web-based config UI)
๐ค Contributing #
Contributions are welcome! Please read our Contributing Guide first.
- Fork the repo
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฌ Support #
- ๐ง Email: [email protected]
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
๐ Show Your Support #
If this project helped you, please โญ the repository and share it with others!
Made with โค๏ธ for the Flutter community