Skip to content

divijsahu/flutter-app-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Flutter App Template - 2026 Enterprise Architecture

Flutter Version License: MIT PRs Welcome

A production-ready Flutter app template following 2026 enterprise architecture principles with clean code, modular design system, and scalable structure. Perfect for starting new projects or learning best practices.

✨ Features

  • πŸ—οΈ Clean Architecture - Domain-driven design with clear separation of concerns
  • 🎨 Design System - Token-based design with atoms, molecules, and organisms
  • πŸ“± Responsive - Mobile, tablet, and desktop layouts out of the box
  • 🎯 Type-Safe - Result types for robust error handling
  • ⚑ Performance - Optimized with Flutter best practices
  • πŸ§ͺ Testable - Every layer independently testable
  • πŸ“š Well Documented - Comprehensive guides and examples
  • πŸ”§ Production Ready - Battle-tested architecture patterns

🎯 Who Is This For?

  • Startups building scalable Flutter apps
  • Enterprise teams needing maintainable architecture
  • Solo developers wanting best practices
  • Students learning Flutter architecture
  • Teams requiring consistent code structure

πŸ“ Project Structure

lib/
β”œβ”€β”€ core/                      # Core infrastructure
β”‚   β”œβ”€β”€ base/                  # Base classes (UseCase, etc.)
β”‚   β”œβ”€β”€ errors/                # Failure types
β”‚   β”œβ”€β”€ network/               # Result type, network utilities
β”‚   └── constants/             # App-wide constants
β”‚
β”œβ”€β”€ design_system/             # Design tokens & components
β”‚   β”œβ”€β”€ tokens/                # Colors, typography, spacing, breakpoints
β”‚   β”œβ”€β”€ theme/                 # Theme configuration
β”‚   β”œβ”€β”€ atoms/                 # Basic UI components (buttons, inputs)
β”‚   β”œβ”€β”€ molecules/             # Composite components
β”‚   β”œβ”€β”€ organisms/             # Complex components
β”‚   └── layouts/               # Layout components (responsive)
β”‚
β”œβ”€β”€ shared/                    # Shared across features
β”‚   β”œβ”€β”€ extensions/            # Context, String extensions
β”‚   β”œβ”€β”€ helpers/               # Snackbar, dialog helpers
β”‚   └── widgets/               # Reusable widgets
β”‚
β”œβ”€β”€ features/                  # Feature modules
β”‚   └── home/
β”‚       β”œβ”€β”€ data/              # Data sources, DTOs, repositories
β”‚       β”œβ”€β”€ domain/            # Entities, use cases, contracts
β”‚       └── presentation/      # Screens, widgets, providers
β”‚
└── app/                       # App configuration
    └── app.dart               # Root app widget

πŸš€ Quick Start

1. Use This Template

Click the "Use this template" button at the top of this repository, or:

# Clone the repository
git clone https://github.com/divijsahu/flutter-app-template.git your-app-name
cd your-app-name

# Remove git history and start fresh
rm -rf .git
git init
git add .
git commit -m "Initial commit from template"

2. Setup Your Project

# Install dependencies
flutter pub get

# Run the app
flutter run

# Run tests
flutter test

# Check for issues
flutter analyze

3. Customize

  1. Update app name in pubspec.yaml
  2. Change package name: flutter pub run change_app_package_name:main com.yourcompany.yourapp
  3. Update constants in lib/core/constants/app_constants.dart
  4. Customize theme in lib/design_system/tokens/
  5. Add your features in lib/features/

πŸ“– Documentation

Quick Guides

Reference

🎨 Design System Usage

Using Design Tokens

// Colors
Container(color: AppColors.primary)

// Spacing
Padding(padding: AppSpacing.pagePadding)

// Typography
Text('Hello', style: AppTypography.headlineMedium)

// Breakpoints
if (MediaQuery.of(context).size.width >= AppBreakpoints.tablet) {
  // Tablet layout
}

Using Components

// Primary Button
PrimaryButton(
  label: 'Submit',
  onPressed: () {},
  isLoading: false,
)

// Responsive Layout
ResponsiveLayout(
  mobile: MobileWidget(),
  tablet: TabletWidget(),
  desktop: DesktopWidget(),
)

Using Context Extensions

// Access theme
context.colors.primary
context.textTheme.bodyLarge

// Check device type
if (context.isMobile) { }
if (context.isTablet) { }
if (context.isDesktop) { }

πŸ—οΈ Architecture Principles

1. Feature Isolation

Each feature is self-contained with its own data, domain, and presentation layers.

2. Dependency Rule

Presentation β†’ Domain ← Data

Domain knows nothing about other layers.

3. Result Type

Use Result<T> for error handling:

Future<Result<User>> login(String email, String password) async {
  try {
    final user = await api.login(email, password);
    return Success(user);
  } catch (e) {
    return Failure(NetworkFailure());
  }
}

4. Use Cases

Business logic lives in use cases:

class LoginUseCase extends BaseUseCase<User, LoginParams> {
  @override
  Future<Result<User>> execute(LoginParams params) {
    // Business logic here
  }
}

πŸ”§ Adding a New Feature

# Create feature structure
mkdir -p lib/features/your_feature/{data,domain,presentation}/{datasources,models,repositories,entities,usecases,screens,widgets,providers}

Follow the clean architecture pattern:

  1. Domain: Define entities and use cases
  2. Data: Implement repositories and data sources
  3. Presentation: Build UI with screens and widgets

See Feature Development Guide for detailed steps.

πŸ“¦ Recommended Packages

dependencies:
  # State Management
  flutter_riverpod: ^2.5.0
  
  # Networking
  dio: ^5.4.0
  
  # Local Storage
  shared_preferences: ^2.2.0
  hive_flutter: ^1.1.0
  
  # Routing
  go_router: ^13.0.0
  
  # Code Generation
  freezed: ^2.4.0
  json_serializable: ^6.7.0

πŸ§ͺ Testing

# Run all tests
flutter test

# Run with coverage
flutter test --coverage

# Generate coverage report
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.html

πŸ“ Best Practices

DO βœ…

  • Use design tokens for all visual properties
  • Follow clean architecture layers
  • Use Result type for error handling
  • Keep features isolated
  • Use context extensions for common operations
  • Make layouts responsive
  • Write tests for business logic

DON'T ❌

  • Hardcode colors, spacing, or text
  • Import from other features
  • Throw exceptions in repositories
  • Skip error handling
  • Assume screen size
  • Put business logic in widgets
  • Repeat code across features

🌟 What's Included

Core Infrastructure

  • βœ… Base classes for UseCase and Repository
  • βœ… Result type for error handling
  • βœ… Failure types (Network, Server, Validation, etc.)
  • βœ… App constants and configuration

Design System

  • βœ… Design tokens (colors, typography, spacing, breakpoints)
  • βœ… Light and dark themes
  • βœ… Atomic components (buttons, inputs, text)
  • βœ… Responsive layouts
  • βœ… Context extensions

Example Feature

  • βœ… Home feature with clean architecture
  • βœ… Responsive home screen
  • βœ… Example of proper layer separation

Documentation

  • βœ… Architecture guide
  • βœ… Design system guide
  • βœ… Feature development guide
  • βœ… Testing guide
  • βœ… Best practices

πŸ”„ Updates and Maintenance

This template is actively maintained. To get updates:

# Add template as upstream
git remote add template https://github.com/divijsahu/flutter-app-template.git

# Fetch updates
git fetch template

# Merge updates (resolve conflicts if any)
git merge template/main --allow-unrelated-histories

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide first.

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Flutter team for the amazing framework
  • Clean Architecture by Robert C. Martin
  • Atomic Design by Brad Frost
  • Flutter community for best practices

πŸ“ž Support

πŸ—ΊοΈ Roadmap

  • Add authentication feature example
  • Add API integration example
  • Add state management examples (Riverpod, Bloc)
  • Add routing example with GoRouter
  • Add form validation examples
  • Add animation examples
  • Add testing examples for all layers
  • Add CI/CD workflow examples

Built with ❀️ using Flutter and 2026 Enterprise Architecture principles.

Star ⭐ this repo if you find it helpful!

About

A Template Repo To Quick Start Your New Flutter Project

Resources

License

Contributing

Stars

4 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors