A production-ready Flutter starter project with Clean Architecture, enterprise-grade configuration management, and comprehensive developer tooling.
- β Clean Architecture - Separation of concerns with Domain, Data, and Presentation layers
- β State Management - Riverpod for reactive state management
- β Code Generation - Freezed for immutable classes and JSON serialization
- β Linting - Very Good Analysis for comprehensive code quality checks
- β Testing - Mocktail for unit testing with comprehensive test coverage
- β Multi-Environment Support - Development, Staging, Production
- β
Flexible Configuration -
.envfiles for local dev,--dart-definefor CI/CD - β Feature Flags - Local and remote (Firebase Remote Config) feature flags
- β Environment-Aware Defaults - Smart defaults based on environment
- β Type-Safe Configuration - Typed getters with fallback chain
- β Multi-Language Support - Flutter localization with ARB files
- β RTL Support - Right-to-left language support
- β Locale Persistence - Save and restore user language preference
- β Secure Storage - Flutter Secure Storage for sensitive data
- β Shared Preferences - Simple key-value storage for non-sensitive data
- β Storage Migration - Version-based storage migration system
- β Error Handling - Comprehensive error handling with custom exceptions
- β HTTP Client - Dio with interceptors support
- β Configurable Timeouts - Environment-based timeout configuration
- β Request/Response Logging - Debug-friendly HTTP logging
- β Error Interceptors - Automatic error handling and conversion
- β Auth Interceptors - Automatic token injection and refresh
- β Material Design - Material 3 theme support
- β Dark Mode - Built-in dark theme support
- β Accessibility - Semantic labels and accessibility support
- β Responsive Design - Adaptive layouts for different screen sizes
- β Type-Safe Routing - GoRouter with type-safe route definitions
- β Deep Linking - Support for deep links and URL navigation
- β Auth-Based Routing - Protected routes with authentication redirects
- β Navigation Logging - Automatic route tracking and logging
- β Comprehensive Logging - Multi-level logging with file and console output
- β Log Rotation - Automatic log file rotation
- β Structured Logging - JSON formatting for production
- β Performance Monitoring - Firebase Performance integration
- β Screen Tracking - Automatic screen load time tracking
- β Multi-Platform - Android, iOS, Web, Linux, macOS, Windows support
- β CI/CD Ready - GitHub Actions workflows included (disabled by default, uncomment triggers to enable)
- β Version Management - Automated version bumping scripts
- β Fastlane Integration - iOS and Android deployment automation
- β Comprehensive Docs - Architecture, guides, API documentation
- β Migration Guides - From MVC, GetX, Bloc, and other architectures
- β Best Practices - Code examples and patterns
- β API Documentation - Complete API reference
- β Example Features - 3 complete example features (Auth, Feature Flags, Tasks)
- β 66 Test Files - Comprehensive test coverage
- β Unit Tests - Domain and data layer testing
- β Widget Tests - UI component testing
- β Integration Tests - End-to-end flow testing
- β Test Helpers - Reusable test utilities and fixtures
- Flutter - UI framework
- Riverpod - State management
- Dio - HTTP client
- Freezed - Code generation for immutable classes
- Equatable - Value equality comparison
- Firebase Core - Firebase initialization
- Firebase Remote Config - Remote feature flags
- Firebase Performance - Performance monitoring and tracking
- flutter_secure_storage - Secure storage for sensitive data
- shared_preferences - Simple key-value storage
- flutter_localizations - Flutter localization support
- intl - Internationalization utilities
- go_router - Declarative routing with deep linking
- logger - Comprehensive logging solution
- path_provider - File system access for log files
- build_runner - Code generation runner
- very_good_analysis - Linting rules
- mocktail - Testing and mocking
lib/
βββ core/ # Core infrastructure
β βββ config/ # Configuration system
β βββ constants/ # App constants
β βββ di/ # Dependency injection (Riverpod providers)
β βββ errors/ # Error handling
β βββ feature_flags/ # Feature flags infrastructure
β βββ localization/ # Localization service
β βββ logging/ # Logging service
β βββ network/ # Network layer (Dio setup)
β βββ performance/ # Performance monitoring
β βββ routing/ # Routing system (go_router)
β βββ storage/ # Storage services (with migration)
β βββ utils/ # Utility functions
β
βββ features/ # Feature modules (Clean Architecture)
β βββ auth/ # Authentication feature example
β β βββ data/ # Data layer (models, data sources, repositories)
β β βββ domain/ # Domain layer (entities, use cases, repository interfaces)
β β βββ presentation/ # Presentation layer (screens, widgets, providers)
β βββ feature_flags/ # Feature flags feature
β β βββ presentation/ # Feature flags UI
β βββ tasks/ # Tasks feature (CRUD example)
β βββ data/ # Data layer
β βββ domain/ # Domain layer
β βββ presentation/ # Presentation layer
β
βββ shared/ # Shared resources
β βββ accessibility/ # Accessibility utilities
β βββ extensions/ # Dart extensions
β βββ theme/ # App theme configuration
β βββ widgets/ # Reusable widgets
β
βββ l10n/ # Localization files (generated)
βββ main.dart # App entry point
- Flutter SDK (>=3.0.0)
- Dart SDK (>=3.0.0)
- Android Studio / VS Code with Flutter extensions
- Xcode (for iOS development on macOS)
-
Create repository from template (if using GitHub template)
- Click "Use this template" button on GitHub
- Create a new repository from this template
- Clone your new repository:
git clone <your-repository-url> cd <your-project-name>
OR clone directly (if not using template):
git clone <repository-url> cd flutter_starter
-
Install dependencies
flutter pub get
-
Generate code (Freezed, JSON serialization)
flutter pub run build_runner build --delete-conflicting-outputs
-
Set up environment configuration
# Copy the example environment file cp .env.example .env # Edit .env with your configuration # See Configuration System section below
-
Set up Git hooks (optional but recommended)
./scripts/setup-git-hooks.sh
This will install Git hooks for:
- Code formatting checks (pre-commit)
- Commit message validation (commit-msg)
- Test execution (pre-push)
-
Run the app
flutter run
- Rename the project (if needed) - Update package name from
flutter_starterto your project name - Configure your environment - See Configuration System below
- Set up Firebase (optional) - For remote feature flags and performance monitoring
- Add
google-services.json(Android) andGoogleService-Info.plist(iOS) - Initialize Firebase in your app
- Add
- Customize the theme - Edit
lib/shared/theme/app_theme.dart - Explore example features - Check out
lib/features/for examples:- Auth - Authentication flow example
- Feature Flags - Feature flags UI example
- Tasks - Complete CRUD example with local storage
- Add your first feature - Follow the pattern in example features
- Read the documentation - Check out
docs/folder for detailed guides
This project includes a production-ready, multi-environment configuration system that supports:
- Local Development:
.envfiles for easy local configuration - CI/CD:
--dart-defineflags for build-time configuration - Fallback Chain:
.envβ--dart-defineβ defaults - Environment-Aware Defaults: Different configurations per environment
- Feature Flags: Enable/disable features per environment
- Network Configuration: Timeout settings for API calls
- Debug Utilities: Tools for inspecting configuration
The configuration system consists of two main classes:
-
EnvConfig(lib/core/config/env_config.dart): Low-level environment variable loader- Loads from
.envfiles usingflutter_dotenv - Reads from
--dart-defineflags - Provides fallback chain:
.envβ--dart-defineβ defaults
- Loads from
-
AppConfig(lib/core/config/app_config.dart): High-level application configuration- Uses
EnvConfigto get values - Provides typed getters (String, bool, int)
- Environment-aware defaults
- Feature flags
- Network timeout configuration
- Debug utilities
- Uses
# Copy the example file
cp .env.example .env
# Edit .env with your values
# The .env file is gitignored and won't be committedEdit .env with your configuration:
ENVIRONMENT=development
BASE_URL=http://localhost:3000
ENABLE_LOGGING=true
ENABLE_ANALYTICS=false- Create
.envfile from.env.example - Fill in your values
- Run the app normally:
flutter runThe app will automatically load values from .env.
For CI/CD or when you don't want to use .env files:
flutter run \
--dart-define=ENVIRONMENT=staging \
--dart-define=BASE_URL=https://api-staging.example.com \
--dart-define=ENABLE_ANALYTICS=trueflutter build apk \
--dart-define=ENVIRONMENT=production \
--dart-define=BASE_URL=https://api.example.com \
--dart-define=ENABLE_ANALYTICS=true \
--dart-define=ENABLE_CRASH_REPORTING=trueimport 'package:flutter_starter/core/config/app_config.dart';
// Get environment
final env = AppConfig.environment; // 'development', 'staging', or 'production'
// Check environment
if (AppConfig.isDevelopment) {
// Development-specific code
}
// Get API base URL
final baseUrl = AppConfig.baseUrl;
// Check feature flags
if (AppConfig.enableLogging) {
logger.info('App started');
}
if (AppConfig.enableAnalytics) {
analytics.trackEvent('app_opened');
}import 'package:flutter_starter/core/config/app_config.dart';
import 'package:dio/dio.dart';
final dio = Dio(
BaseOptions(
baseUrl: AppConfig.baseUrl,
connectTimeout: Duration(seconds: AppConfig.apiConnectTimeout),
receiveTimeout: Duration(seconds: AppConfig.apiReceiveTimeout),
sendTimeout: Duration(seconds: AppConfig.apiSendTimeout),
),
);import 'package:flutter_starter/core/config/app_config.dart';
// Print configuration to console (only in debug mode)
AppConfig.printConfig();
// Get configuration as a map
final config = AppConfig.getDebugInfo();
print(config);| Variable | Type | Default | Description |
|---|---|---|---|
ENVIRONMENT |
String | development |
Environment name: development, staging, or production |
BASE_URL |
String | Environment-aware | API base URL (see defaults below) |
API_TIMEOUT |
int | 30 |
API timeout in seconds |
API_CONNECT_TIMEOUT |
int | 10 |
API connect timeout in seconds |
API_RECEIVE_TIMEOUT |
int | 30 |
API receive timeout in seconds |
API_SEND_TIMEOUT |
int | 30 |
API send timeout in seconds |
ENABLE_LOGGING |
bool | Environment-aware | Enable logging (default: true in dev/staging) |
ENABLE_ANALYTICS |
bool | Environment-aware | Enable analytics (default: true in staging/prod) |
ENABLE_CRASH_REPORTING |
bool | Environment-aware | Enable crash reporting (default: true in staging/prod) |
ENABLE_PERFORMANCE_MONITORING |
bool | Environment-aware | Enable performance monitoring (default: true in staging/prod) |
ENABLE_DEBUG_FEATURES |
bool | Environment-aware | Enable debug features (default: true in dev) |
ENABLE_HTTP_LOGGING |
bool | Environment-aware | Enable HTTP request/response logging (default: true in dev) |
APP_VERSION |
String | 1.0.0 |
App version |
APP_BUILD_NUMBER |
String | 1 |
App build number |
BASE_URL defaults:
- Development:
http://localhost:3000 - Staging:
https://api-staging.example.com - Production:
https://api.example.com
Feature Flag defaults:
- Logging: Enabled in
developmentandstaging - Analytics: Enabled in
stagingandproduction - Crash Reporting: Enabled in
stagingandproduction - Performance Monitoring: Enabled in
stagingandproduction - Debug Features: Enabled in
developmentonly - HTTP Logging: Enabled in
developmentonly
- Never commit
.envfiles: They contain sensitive information and are gitignored - Use
.env.exampleas a template: Commit this file with placeholder values - Use
.envfor local development: Easy to change values without rebuilding - Use
--dart-definefor CI/CD: More secure and doesn't require file management - Set environment-specific defaults: Let the system handle defaults based on environment
- Use feature flags: Enable/disable features per environment without code changes
- Ensure
EnvConfig.load()is called inmain()beforerunApp() - Check that
.envfile exists in the project root - Verify
pubspec.yamlincludes.envin assets - Run
flutter pub getafter addingflutter_dotenv
- Hot reload doesn't reload environment variables - do a full restart
- For
--dart-definevalues, rebuild the app - Check that you're using the correct variable name (case-sensitive)
Use AppConfig.printConfig() in debug mode to see all configuration values:
if (AppConfig.isDebugMode) {
AppConfig.printConfig();
}This will print all configuration values to the console, helping you verify what values are being used.
# Run all tests
flutter test
# Run tests with coverage
flutter test --coverage
# Run specific test file
flutter test test/features/auth/domain/usecases/login_test.dartTests follow the same structure as the source code:
- 66 test files with comprehensive coverage
- Unit tests for use cases and utilities
- Widget tests for UI components
- Integration tests for end-to-end flows
- Test helpers and fixtures for reusable test utilities
The project includes:
- β Domain layer tests (use cases, entities)
- β Data layer tests (repositories, data sources, models)
- β Presentation layer tests (screens, widgets, providers)
- β Core infrastructure tests (config, network, storage, logging, performance)
- β Integration tests for complete flows
# Debug APK
flutter build apk --debug
# Release APK
flutter build apk --release
# App Bundle (for Play Store)
flutter build appbundle --release# Debug
flutter build ios --debug
# Release
flutter build ios --release# Debug
flutter build web --debug
# Release
flutter build web --release- Architecture Documentation - Complete architecture documentation index
- Architecture Overview - Why Clean Architecture, benefits, trade-offs, and learning resources
- Design Decisions - Detailed rationale for routing, state management, error handling, logging, storage, and HTTP client choices
- Getting Started - Step-by-step setup guide
- Understanding the Codebase - Architecture and patterns
- Common Tasks - Frequently performed tasks
- Routing Guide - GoRouter navigation and deep linking
- Git Hooks Setup - Setup Git hooks for code quality (similar to Husky)
- Adding Features - How to add new features
- Feature Flags - Feature flags system documentation
- Tasks Feature - CRUD example feature documentation
- Localization - i18n setup and usage
- Logging - Logging system documentation
- Performance - Performance monitoring guides
- Routing - Routing and navigation guide
- Deployment Guide - Complete deployment documentation
- Quick Start - Get started in 5 minutes
- Android Deployment - Android-specific guide
- iOS Deployment - iOS-specific guide
- Web Deployment - Web-specific guide
- Release Process - Version management and releases
- Monitoring & Analytics - Crashlytics and analytics setup
- API Overview - API documentation index
- Examples - Code examples and patterns
We welcome contributions! Please see our Contributing Guide for details on:
- How to report bugs
- How to suggest enhancements
- Development setup and workflow
- Coding standards and guidelines
- Testing requirements
- Commit message conventions
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes following our coding standards
- Write or update tests
- Commit your changes using conventional commits
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For detailed guidelines, please read CONTRIBUTING.md.
This project is licensed under the MIT License - see the LICENSE file for details.
- Flutter - The framework
- Riverpod - State management
- Very Good Ventures - Linting rules and best practices
- Freezed - Code generation
For questions, issues, or contributions, please open an issue on GitHub.
Made with β€οΈ using Flutter