This is an example weather app made with Flutter using Riverpod as a state management solution. The app is using https://open-meteo.com as a weather API.
# Install flutter packages
flutter pub get
# Run code generation to generate all needed classes
flutter dart run build_runner watch -d
The following technical features are implemented in the app:
- Search with caching and debouncing
- API request caching
- State management with Riverpod
- Flutter Material3 design system
- Persistent state through SharedPreferences
- Light and dark theme
- Flutter
- Riverpod with code generation for state management, DI and caching
- Freezed for the data models to generate essential methods like toString, ==, hashCode and to handle de/serialization of the data
- Dio as an HTTP client
- Flutter hooks for reusable widget logic
- Shared Preferences for persistent storage
- Flutter native splash to customize the splash screen
The app follows a Model-View-ViewModel (MVVM) architectural pattern with a layer-first project structure.
The application is split into three separate layers:
- Presentation layer: Flutter widgets and Riverpod providers (ViewModels)
- Domain layer: Data models with business logic
- Data layer: Repositories to access the data
Note
For more complex projects, an additional application/service layer can be introduced between the presentation and domain layers to handle the business logic separately, rather than embedding it within the models.
The Riverpod providers act as ViewModels to establish data bindings and update the UI as needed. The providers retrieve their data from repositories, making the repositories easily replaceable and ensuring a clear separation of concerns.
weather_app/
├── android/
├── ios/
├── lib/
│ ├── main.dart # Entry point of the application
│ ├── ui
│ │ ├── pages/ # Main pages of the app
│ │ ├── views/ # View components that are included on the pages
│ │ └── widgets/ # Reusable widgets
│ ├── provider/ # Riverpod provider managing the state of the app
│ ├── models/ # Data models of the app
│ └── repositories/ # Data access through API calls
├── assets/
├── test/
├── pubspec.yaml
└── README.md