A modern Flutter application showcasing the MVVM (Model-View-ViewModel) architecture pattern with clean code principles. This app fetches and displays tech news in a vintage newspaper style interface.
This project implements the MVVM (Model-View-ViewModel) architecture pattern, which provides a clean separation of concerns:
- Represents the data and business logic
- Located in
lib/features/*/domain/models - Uses Freezed for immutable data classes
- Handles data validation and transformation
- UI layer that displays data to users
- Located in
lib/features/*/presentation/views - Stateless where possible for better performance
- Uses Riverpod Consumer widgets to observe ViewModels
- Implements responsive and adaptive designs
- Manages UI state and business logic
- Located in
lib/features/*/presentation/viewmodels - Uses Riverpod for state management
- Handles data operations and transformations
- Provides UI-ready data to Views
- State Management: Riverpod 2.4.9 for reactive and testable state management
- Navigation: go_router 13.0.1 for declarative routing
- API Integration: Dio for HTTP networking with interceptors
- Code Generation:
- Freezed for immutable models
- JSON serialization
- Riverpod generators
- Performance Optimizations:
- Efficient color operations with withAlpha
- Lazy loading and pagination
- Shimmer loading effects
- Modern UI:
- Vintage newspaper design
- Custom Google Fonts
- Responsive layouts
- Smooth animations
lib/
├── core/ # Core functionality and utilities
│ ├── api/ # API client and response handling
│ ├── theme/ # App theme and styling
│ └── widgets/ # Reusable widgets
│
└── features/ # Feature modules
└── news/ # News feature
├── data/ # Data layer (repositories)
├── domain/ # Business logic and models
└── presentation/ # UI layer
├── viewmodels/
└── views/
dependencies:
flutter_riverpod: ^2.4.9
riverpod_annotation: ^2.3.3
go_router: ^13.0.1
google_fonts: ^6.1.0
shimmer: ^3.0.0
url_launcher: ^6.2.2
dio: ^5.4.0
freezed_annotation: ^2.4.1
json_annotation: ^4.8.1
dev_dependencies:
build_runner: ^2.4.7
freezed: ^2.4.6
json_serializable: ^6.7.1
riverpod_generator: ^2.3.9- Clone the repository
git clone https://github.com/AndreyDAraya/flutter_mvvm.git- Install dependencies
flutter pub get- Run code generation
flutter pub run build_runner build --delete-conflicting-outputs- Run the app
flutter run- Views observe ViewModels using Riverpod providers
- ViewModels handle business logic and data operations
- Models represent the data structure and validation
- Repositories handle data fetching and caching
- API client manages network requests
- Feature-First Structure: Organized by feature for better scalability
- Clean Architecture Principles: Clear separation of concerns
- Dependency Injection: Using Riverpod for better testability
- Immutable State: Using Freezed for reliable state management
- Declarative UI: Flutter widgets with clear responsibilities
- Error Handling: Consistent error handling through ApiResponse class
- Efficient color operations using withAlpha instead of withOpacity
- Lazy loading for better memory management
- Shimmer loading for better UX during data fetching
- Hero animations for smooth transitions
- Pagination for handling large datasets
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request