A modern Flutter application template following the MVVM (Model-View-ViewModel) architecture pattern with a clean architecture approach. This project serves as a solid foundation for building scalable, maintainable, and testable Flutter applications.
This project implements a feature-first, layered architecture inspired by Clean Architecture principles:
- Domain Layer: Contains business logic and rules, independent of any UI or external frameworks
- Data Layer: Implements repositories defined in the domain layer and handles data sources
- Presentation Layer: Contains UI components and ViewModels that connect the UI with the domain layer
- Infrastructure Layer: Provides supporting functionality like authentication, navigation, and storage
lib/
├── app.dart # Main application widget
├── main.dart # Entry point
├── features/ # Feature modules
│ ├── auth/ # Authentication feature
│ ├── forms/ # Forms feature
│ ├── home/ # Home feature
│ ├── profile/ # Profile feature
│ ├── settings/ # Settings feature
│ └── splash/ # Splash screen feature
└── shared/ # Shared code across features
├── core/ # Core utilities and constants
├── data/ # Shared data layer components
├── domain/ # Shared domain layer components
├── infrastructure/ # Shared infrastructure components
└── presentation/ # Shared UI components
- State Management: Flutter Riverpod with riverpod_annotation
- Navigation: GoRouter for declarative routing
- API Integration: Supabase Flutter for backend services
- Data Classes: Freezed for immutable data models
- Functional Programming: FPDart for functional programming patterns
- Forms: Reactive Forms for form handling
- Responsive UI: Responsive Framework & Flutter ScreenUtil
- Secure Storage: Flutter Secure Storage
- Dependency Injection: Riverpod
- Logging: Logger package
- Flutter SDK (^3.6.0)
- Dart SDK (^3.6.0)
- FVM (optional but recommended for version management)
-
Clone the repository
git clone https://github.com/mobpack/flutter_mvvm_base.git cd flutter_mvvm_base -
Install dependencies
flutter pub get
-
Create a
.envfile in the root directory with your environment variablesSUPABASE_URL=your_supabase_url SUPABASE_ANON_KEY=your_supabase_anon_key -
Run the app
flutter run
- Follow the MVVM pattern for all features
- Keep the domain layer independent of external frameworks
- Use repositories to abstract data sources
- Implement ViewModels using Riverpod providers
- Follow Dart and Flutter best practices for code style and readability
- Use meaningful naming conventions for files, classes, methods, and variables
- Break code into small, reusable widgets and functions
- Document all public APIs, classes, and complex logic with DartDoc comments
- Prefer stateless widgets unless state is required
- Use ConsumerWidget for screens and widgets that require state management
- Leverage Dart's null safety features and avoid nullable types unless necessary
- Use const constructors for better performance
- Write unit tests for business logic and ViewModels
- Write widget tests for UI components
- Write integration tests for critical user flows
- Aim for high test coverage
- Create a feature branch from the main branch
- Implement your changes following the project's architecture and coding standards
- Add tests for your changes
- Run
flutter analyzeandflutter formatbefore committing - Submit a pull request for review
This project is licensed under the MIT License - see the LICENSE file for details.