PetraCore Flutter Frontend Starter
A powerful CLI tool and package for generating Flutter projects with clean architecture, Firebase integration, and industry best practices. Based on proven patterns from production applications.
โจ Features
- ๐๏ธ Clean Architecture: Feature-based modular structure with clear separation of concerns
- ๐ฅ Firebase Integration: Pre-configured Firestore, Analytics, and Cloud Messaging
- ๐จ Design Presets: Choose from default, Vercel, Airbnb, or Apple design presets via
app_ui_kit - ๐จ Modern UI: Responsive design and comprehensive component library
- ๐งฉ BLoC Pattern: Predictable state management with Hydrated BLoC
- ๐ CLI Tools: Generate projects and features instantly
- ๐ Complete Authentication: Full auth flow with login, signup, OTP, email verification
- ๐ฑ Multi-platform: iOS, Android, Web, macOS, Windows, Linux support
- ๐ Security: Secure storage, environment variables, and authentication patterns
- ๐ฏ Best Practices: Linting rules, code generation, and project structure
- ๐ฆ Rich Packages: Carefully selected and battle-tested dependencies
- โจ Enhanced CLI: Beautiful, professional logging with levels (debug, info, warning, error, success) and colored output for improved user experience
- ๐งฉ Service Bootstrap: Add services, repositories, use cases, and BLoCs to existing features with
petracore service
๐ Recent Improvements (v1.1.0)
- ๐งฉ Service Bootstrap Command:
petracore service <service_name>interactively bootstraps a new service inside an existing feature with optional model, repository, use cases, and BLoC/Cubit โ all wired into the feature's barrel files and shared BlocProvider automatically - ๐ฌ Complete Chat Feature:
petracore feature chatnow generates a full chat feature with:- Firestore-backed real-time messaging with chat & message models
- Chat list screen with
flutter_slidableswipe-to-delete - Chat detail screen with message bubbles, file sharing, and media preview
- Cloudinary CDN upload integration โ files picked via
file_pickerare uploaded to Cloudinary before sending - Voice/video call screens with call log, calling mode toggle, participant cards
- Group chat support โ create group, group info screen, member management
AttachmentSheetwith gallery, camera, video, document, and audio optionsopen_filextap-to-open for file-type messages- All dependencies (
flutter_slidable,file_picker,open_filex,image_picker,cloud_firestore) auto-injected intopubspec.yaml flutter pub getruns automatically after generation
- ๐๏ธ MediaType Enum Removed: Replaced the custom
MediaTypeenum withString? mimeTypeacross both chat and media features โ eliminates type conflicts and aligns with standard MIME type conventions. AllisImage/isVideo/isFilechecks now usemimeType?.startsWith(...)patterns - ๐
FileUploadDtoSimplified:fileType: MediaTypeโmimeType: String?in the media feature's Cloudinary DTO - โป๏ธ Design Preset Simplification: Removed the entire local
DesignPresetId/DesignPresetclass hierarchy. Preset names are now plain strings โ no local color/typography/radius definitions. All visual tokens come fromapp_ui_kitviaAppUiKitPresetin generatedbootstrap.dart --design-presetValues: Thedesign-presetCLI option accepts the same 12 preset names:default,vercel,airbnb,apple,spotify,vibrant,highContrast,starbucks,linear,notion,mongodb,raycast--include-authFlag: Generate auth alongside the project in one step โpetracore init my_app --include-authapp_ui_kitTheming: All theme and component generation removed locally. Everything comes from theapp_ui_kitpackage (AppScaffold,AppUiKit.themes, design presets)- Route Deduplication: Auth route constants no longer duplicate on rerun โ safe to generate auth multiple times
- AnimatedSplashLogo Fix: Splash screen logo widget is now correctly generated to disk
- Screen Consolidation: Flat screen directory structure, no more material/mix subdirectories
๐ What You Get
Project Structure
your_project/
โโโ lib/
โ โโโ app/ # App-level configuration
โ โ โโโ constants/ # App constants and string values
โ โ โโโ view/ # Main app widget
โ โ โโโ theme/ # Color values (brand palette from design preset)
โ โโโ core/ # Shared utilities and components
โ โ โโโ components/ # Reusable UI components
โ โ โโโ data/ # Core data services and domain logic
โ โ โโโ utils/ # Utility functions and extensions
โ โโโ features/ # Feature modules (clean architecture)
โ โ โโโ main_app/ # Dashboard screen (auto-generated)
โ โ โโโ shared/ # Shared feature components
โ โโโ navigation/ # App navigation and routing
โ โโโ main.dart # Entry point
โโโ assets/ # Images, SVGs, Lottie files
โโโ fonts/ # Custom fonts
โโโ firebase.json # Firebase configuration
โโโ analysis_options.yaml # Comprehensive linting rules
Key Components
- Bootstrap Pattern: Centralized app initialization with error handling
- Repository Pattern: Data layer abstraction for testability
- Use Cases: Business logic separation following Clean Architecture
- BLoC/Cubit: State management with persistence
- Custom Components: Buttons, text fields, scaffolds, loading states
- Navigation: Declarative routing with GoRouter
- Extensions: Handy utilities for strings, context, and more
๐ Installation
Global Installation (Recommended)
dart pub global activate petracore_flutter_frontend_starter
Local Installation
dart pub add petracore_flutter_frontend_starter
๐ Usage
Create a New Project
# Interactive mode (prompts for design preset, auth, etc.)
petracore init my_awesome_app
# With specific design preset (skips interactive prompt)
petracore init my_app --design-preset apple
# Generate with auth feature included
petracore init my_app --include-auth
# With custom organization
petracore init my_app --org com.mycompany
# With custom description
petracore init my_app --description "My amazing Flutter application"
# Force overwrite existing directory
petracore init existing_app --force
# Skip all interactive prompts (uses defaults)
petracore init my_app --no-interactive
Generate Features
# Generate a complete feature with all components (BLoC provider auto-registered)
petracore feature user_profile
# Generate feature without BLoC
petracore feature simple_feature --no-bloc
# Generate feature with custom output directory
petracore feature profile --output lib/modules
# Generate feature without models
petracore feature ui_feature --no-models
# Alternative syntax
petracore generate feature chat
Note: When generating features with BLoC enabled, the CLI automatically registers the feature's BLoC provider in
lib/features/shared/presentation/controllers/bloc_provider.dart. No manual editing needed.
Generate Complete Authentication Flow
# Generate auth alongside project (recommended โ one step)
petracore init my_app --include-auth
# Or generate auth in an existing project (interactive)
petracore auth
# Non-interactive with specific features
petracore auth --no-interactive --login --signup --forgot-password --otp
# Full auth flow with all features
petracore auth --login --signup --email-verification --forgot-password --phone-verification --otp --social-auth --device-token
# Basic auth setup
petracore auth --no-interactive --login --signup
Generate Complete Media Feature
# Interactive mode - choose full media or basic feature
petracore feature media
# Full media feature with Cloudinary, image picker, BLoCs, and widgets
# Auto-detected "media" keyword prompts for complete setup
Generate Complete Chat Feature
# Interactive mode - choose full chat or basic feature
petracore feature chat
# Full chat feature with:
# - Firestore real-time messaging
# - Cloudinary file upload integration
# - Voice/video call screens
# - Group chat support
# - File sharing with AttachmentSheet
# Auto-detected "chat" keyword prompts for complete setup
Bootstrap a Service Into an Existing Feature
# Interactive prompt walks you through the setup
petracore service payment
# The command asks:
# 1. Which existing feature to add the service to
# 2. Whether to create a model (with DTOs and Params)
# 3. Whether to create a repository (name defaults to <service>_repository)
# 4. Whether to create use cases (name defaults to <service>_use_cases)
# 5. Whether to create BLoC/Cubit (prefix defaults to the entity name)
#
# All generated files are automatically exported in the feature's barrel
# index and the shared BlocProvider is updated if BLoCs are added.
The service command is ideal for adding new API integrations to an existing feature. For example, if you have a shop feature and want to add a payment service:
petracore service payment
# Feature name: shop
# Create a model? (y/N): y
# Model name: transaction
# Create a repository? (Y/n): (enter)
# Create use cases? (Y/n): (enter)
# Create BLoC/Cubit? (Y/n): (enter)
This generates:
data/remote/payment_service.dartโ Dio-based API servicedata/remote/payment_repository.dartโ Repository with Either patterndata/models/transaction_model.dartโ Model + DTOs + Paramsdata/domain/payment_use_cases.dartโ Create/Delete/Get/Update use casespresentation/controllers/โ Cubit, Action BLoC, Data BLoC, BlocProvider- Updates
shop_index.dart,presentation.dart, and sharedBlocProvider
Available Options
Init Command Options
--design-preset: Design preset -default(default),vercel,airbnb, orapple--include-auth: Generate auth feature alongside the project--no-interactive: Skip interactive prompts and use defaults--org: Organization identifier (default: com.petracore)--description: Project description--force: Force creation even if directory exists--verbose: Enable detailed output
Feature Command Options
--bloc/--no-bloc: Include BLoC/Cubit (default: true)--repository/--no-repository: Include repository pattern (default: true)--use-cases/--no-use-cases: Include use cases (default: true)--models/--no-models: Include data models (default: true)--list: Include a list screen for the feature (default: false)--output: Custom output directory (default: lib/features)
Auth Command Options
--login/--no-login: Include login functionality (default: true)--signup/--no-signup: Include signup functionality (default: true)--email-verification: Include email verification (default: false)--forgot-password: Include forgot password functionality (default: false)--phone-verification: Include phone verification (default: false)--otp: Include OTP (One-Time Password) functionality (default: false)--social-auth: Include social authentication placeholders (default: false)--device-token: Include device token support for push notifications (default: false)--interactive/--no-interactive: Use interactive mode (default: true)--output: Output directory (default: current directory)
๐ง Generated Architecture
Feature Structure
Each generated feature follows this structure:
features/your_feature/
โโโ your_feature_index.dart # Barrel export file (exports models directly)
โโโ data/
โ โโโ models/
โ โ โโโ your_feature_model.dart # Data models with JSON serialization
โ โโโ remote/
โ โ โโโ your_feature_service.dart # API service
โ โ โโโ your_feature_repository.dart # Repository interface & implementation
โ โ โโโ dto/
โ โ โโโ create_your_feature_dto.dart
โ โ โโโ update_your_feature_dto.dart
โ โ โโโ your_feature_params.dart
โ โโโ domain/
โ โโโ your_feature_use_cases.dart # Business logic use cases
โโโ presentation/
โโโ controllers/
โ โโโ cubits/
โ โ โโโ your_feature_cubit.dart # Cubit state management
โ โโโ blocs/
โ โ โโโ multiple_your_feature_bloc/ # Data BLoC (multi-state)
โ โ โ โโโ multiple_your_feature_bloc.dart
โ โ โ โโโ multiple_your_feature_event.dart
โ โ โ โโโ multiple_your_feature_state.dart
โ โ โโโ your_feature_action_bloc/ # Action BLoC (single-state)
โ โ โโโ your_feature_action_bloc.dart
โ โ โโโ your_feature_action_event.dart
โ โ โโโ your_feature_action_state.dart
โ โโโ your_feature_bloc_provider.dart # BLoC provider (auto-registered)
โ โโโ your_feature_controller_index.dart
โโโ screens/
โ โโโ your_feature_screen.dart # Main feature screen
โ โโโ your_feature_screens_index.dart
โโโ widgets/
โโโ presentation.dart # Presentation barrel export
Core Packages Included
# Architecture & State Management
flutter_bloc: ^8.1.3 # Predictable state management
hydrated_bloc: ^9.1.5 # State persistence
provider: ^6.0.2 # Dependency injection
equatable: ^2.0.5 # Value equality
# Navigation
go_router: ^10.0.0 # Declarative routing
# UI & Design
flutter_screenutil: ^5.4.0 # Responsive design
flutter_hooks: ^0.18.6 # React-like hooks
animations: ^2.0.7 # Rich animations
gap: ^3.0.1 # Spacing widgets
google_fonts: ^4.0.4 # Custom fonts
cached_network_image: ^3.2.3 # Optimized image loading
lottie: ^2.2.0 # Lottie animations
# Network & API
dio: ^5.3.3 # HTTP client
pretty_dio_logger: ^1.4.0 # Request/response logging
# Security & Storage
flutter_secure_storage: ^9.0.0 # Secure key-value storage
flutter_dotenv: ^5.0.2 # Environment variables
# Code Generation
json_serializable: ^6.8.0 # JSON serialization
build_runner: ^2.4.11 # Code generation runner
# Functional Programming
dartz: ^0.10.1 # Functional programming utilities
# Firebase (optional)
firebase_core: ^3.12.1 # Firebase core
cloud_firestore: ^5.6.5 # Cloud Firestore
firebase_analytics: ^11.4.4 # Analytics
firebase_messaging: ^15.2.4 # Cloud Messaging
๐ ๏ธ Development Workflow
After Creating a Project
-
Navigate to your project:
cd your_project_name -
Install dependencies:
flutter pub get -
Generate code (for models):
flutter packages pub run build_runner build -
Run your app:
flutter run
Adding New Features
-
Generate the feature:
petracore feature user_profile -
BLoC provider auto-registered: The CLI automatically adds the feature's BLoC provider to
lib/features/shared/presentation/controllers/bloc_provider.dart- no manual step needed. -
Generate code (if using models):
flutter packages pub run build_runner build -
Navigation routes are auto-registered: Both auth and feature generators automatically register routes in
lib/navigation/routes.dart(using theRoutedata class), create a per-feature route list inlib/navigation/routes/<feature>_routes.dart, and updaterouter.dartโ no manual editing needed.
Adding Services to Existing Features
-
Bootstrap the service:
petracore service payment -
Follow the prompts to optionally create a model, repository, use cases, and BLoC/Cubit.
-
All wiring is automatic: The feature's barrel index is updated with new exports, the presentation barrel registers new controllers, and the shared
BlocProvideris updated if BLoCs are generated โ no manual editing needed.
๐จ Design Presets & Theming
PetraCore uses the app_ui_kit package for all theming and UI components โ no theme files are generated locally.
Design Presets
Choose a preset when creating a project with --design-preset:
- default: Balanced defaults suitable for most products
- vercel: Minimal, geometric design language inspired by Vercel
- airbnb: Warm and rounded consumer UI inspired by Airbnb
- apple: San Francisco typography and clean surfaces inspired by Apple
- spotify: Green-on-dark, media-centric style inspired by Spotify
- vibrant: Saturated palettes with denser visual rhythm
- highContrast: Maximum readability with strong foreground/background separation
- starbucks: Warm neutrals with layered green palette inspired by Starbucks
- linear: Precise dark interface with lavender accent inspired by Linear
- notion: Calm neutral canvas with blue accent inspired by Notion
- mongodb: Developer-focused green with dark surfaces inspired by MongoDB
- raycast: Utility-dark shell with crisp neutrals inspired by Raycast
Color Values
lib/app/theme/color_values.dart is generated as the source of truth for brand colors:
- Primary, secondary, technical colors
- Neutral palette (50-600 scale)
- Error, success, warning, info states
- Surface colors (white, black, overlays)
Components
All components (AppScaffold, BaseScaffold, buttons, inputs, etc.) come from app_ui_kit. Use AppUiKit.themes to access the active theme. Modify color_values.dart to customize brand colors โ all theme colors derive from these values.
๐จ Customization
Themes and Design
- Modify
lib/app/theme/color_values.dartto customize brand colors - Update
lib/app/constants/app_constants.dartfor design tokens - Add custom fonts to
fonts/directory
Components
- Extend components in
lib/core/components/ - Add new utilities in
lib/core/utils/ - Create custom extensions in
lib/core/utils/extensions/
Configuration
- Environment variables in
env.json - App-level config in
lib/app/app/constants/
๐งช Testing
The generated project includes:
- Unit test structure in
test/ - Widget test examples
- BLoC testing patterns
- Repository testing with mocks
Run tests:
flutter test
๐ Examples
Creating a Complete App
# Create a full-featured app with auth included
petracore init social_media_app \
--org com.yourcompany \
--description "A social media application with real-time features" \
--include-auth
cd social_media_app
flutter pub get
# Generate core features
petracore feature user_profile
petracore feature feed
petracore feature chat # Full chat with calls, groups, file sharing
# Generate code and run
flutter packages pub run build_runner build
flutter run
Authentication Flow Examples
# Complete authentication flow (interactive)
petracore auth
# Full-featured auth with all options
petracore auth --no-interactive \
--login --signup --email-verification \
--forgot-password --otp --social-auth
# Basic login/signup only
petracore auth --no-interactive --login --signup
# Auth with OTP verification
petracore auth --no-interactive --login --signup --otp
Feature Generation Examples
# Basic feature generation
petracore feature user_profile
# Simple UI-only feature
petracore feature settings --no-bloc --no-repository --no-use-cases
# Complex feature with custom location
petracore feature payment \
--output lib/modules \
--bloc \
--repository \
--use-cases \
--models
# Bootstrap a service into an existing feature
petracore service payment
๐ Advanced Usage
Custom Templates
You can extend the CLI by creating your own templates in the templates/ directory.
Integration with Existing Projects
The feature generator works with any Flutter project that follows similar conventions.
CI/CD Integration
The generated projects include:
- GitHub Actions workflows (coming soon)
- Proper linting configuration
- Testing setup
- Build configuration
Development Setup
git clone https://github.com/yourusername/petracore_flutter_frontend_starter.git
cd petracore_flutter_frontend_starter
dart pub get
# Run tests
dart test
# Test CLI locally
dart run bin/main.dart --help
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with inspiration from clean architecture principles
- Based on patterns from production Flutter applications
- Incorporates Flutter community best practices
๐ Support
- ๐ Issues: GitHub Issues
Made with โค๏ธ by the PetraCore Team
Libraries
- petracore_flutter_frontend_starter
- PetraCore Flutter Frontend Starter