flutter_setup_cli 1.0.1 copy "flutter_setup_cli: ^1.0.1" to clipboard
flutter_setup_cli: ^1.0.1 copied to clipboard

CLI tool to scaffold a clean-architecture core folder for new Flutter projects.

Flutter Setup CLI 🚀 #

A CLI tool to scaffold a clean-architecture core folder structure for new Flutter projects. Get your project started instantly with best practices in dependency injection, routing, error handling, and API integration.

Features #

  • Clean Architecture: Automatic creation of core, config, features, and utils folders.
  • Dependency Injection: Pre-configured get_it setup with ApiService and SecureStorage.
  • Routing: Ready-to-use go_router configuration with authentication flow.
  • API Layer: Includes Dio with RetryInterceptor and AuthInterceptor.
  • Storage: Secure token storage using flutter_secure_storage.
  • Error Handling: Comprehensive Failures and Exceptions hierarchy.
  • Ready to Run: Generates a fully wired main.dart — the app runs immediately.

Installation #

Install the CLI globally from pub.dev:

dart pub global activate flutter_setup_cli

⚠️ Important: Run This First, on a Brand-New Project #

This CLI is meant for the very first setup step of a Flutter project — right after flutter create, before you've written any of your own code.

main.dart is generated completely from scratch and will overwrite whatever flutter create put there (the default counter app). If you run this on a project that already has real work in main.dart, you will lose it. Back up or commit your existing main.dart first if you're unsure.

No backend yet? That's fine — when prompted for your API base URL, you can enter any placeholder (e.g. https://api.example.com). Nothing is validated at setup time; just update the value in lib/config/app_constants.dart later once your real backend is ready.

Usage #

Navigate to your new Flutter project and run the command:

flutter_setup

The CLI will:

  1. Prompt you to enter your API base URL.
  2. Generate the complete directory structure inside lib/.
  3. Add all necessary dependencies (dio, fpdart, get_it, flutter_secure_storage, go_router) to your pubspec.yaml.
  4. Wire up main.dart to initialize dependency injection and boot straight into go_router.

Example Workflow #

# Create a new Flutter project (if you haven't already)
flutter create my_awesome_app
cd my_awesome_app

# Run the setup CLI
flutter_setup

# Enter your API URL when prompted (a placeholder is fine)
Enter your base api url: https://api.example.com

Project Structure #

The CLI generates the following folder structure:

lib/
├── main.dart                  # App entry point — overwritten, DI + router wired in
├── config/
│   ├── app_colors.dart
│   ├── app_constants.dart
│   └── routes/
│       └── app_router.dart
├── core/
│   ├── di/                    # Dependency Injection setup
│   │   └── dependency_injection.dart
│   ├── error/                 # Error handling
│   │   ├── exceptions.dart
│   │   └── failures.dart
│   ├── network/               # Networking
│   │   ├── api_service.dart
│   │   ├── dio_client.dart
│   │   ├── safe_api_call.dart
│   │   └── interceptors/
│   │       ├── auth_interceptor.dart
│   │       └── retry_interceptor.dart
│   └── storage/                # Secure storage
│       └── app_secure_storage.dart
├── features/                  # Feature modules (empty, ready to use)
└── utils/                     # Utilities (empty, ready to use)

What Gets Generated #

File Purpose
main.dart App entry point — overwrites the default file, initializes DI, boots MaterialApp.router
app_colors.dart Starter color token constants
app_constants.dart Stores your API base URL
app_router.dart go_router setup with an auth-based redirect and one placeholder route
dependency_injection.dart get_it registrations for storage, Dio, and ApiService
failures.dart / exceptions.dart Error-handling type hierarchy
api_service.dart / dio_client.dart Abstract API contract and its Dio-backed implementation
safe_api_call.dart Wraps API calls, converting DioExceptions into typed Failures
auth_interceptor.dart Attaches a bearer token to outgoing requests
retry_interceptor.dart Retries failed requests with exponential backoff
app_secure_storage.dart Secure storage for the access token

License #

MIT License — see LICENSE for details.

1
likes
160
points
120
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

CLI tool to scaffold a clean-architecture core folder for new Flutter projects.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on flutter_setup_cli