A new Flutter project for consuming images and marking them as favorites.
As Image Source - the project uses pixabay.
- After downloading the project - set your key from https://pixabay.com/api/docs/ to the env.dart
- Execute - dart run build_runner build --delete-conflicting-outputs
- Run the App
The App consists of:
- Home Screen - with the feature to search, go to favorites, go to details on image tab
- Recent Searches Functionality - inside the home search field
- Favorites Screen - very similar to Home with focus on fav images
- Details Screen - Bigger view and more details about the image. Feature - add/remove from fav.
The app's code is organized in layers
- Data Access - Wrappers for the Information Sources - external to the App and - the Flutter Engine
- Repositories - Wrapper for the Data Access - so any exceptions, external (from flutter, or from a package) data models are mapped to internal and known objects
- Services - In many cases services are just thin bridge between the view+bloc and the data sources. Here is a perfect play for business logic with strict expected input -> output, so they could be wrapped in unit test
- BloCs - Controllers of the state of the screens
- Local DIs for Blocs
- Views / Components / Widgets
- Global DI
- Routing
- I18n (execute 'flutter gen-l10n' after each translation change (in lib/l10n/*.arb))
The code structure is inspired by the Rx Bloc ecosystem with few replacements for less code generation and simplicity.
- GetIt is used for DI instead of provider
- BloC is used instead of the flutter_rx_bloc
- it uses freezed for from/to json, equals, copyWith
- Navigator 1.0 - instead of go_router
- ...
The Project includes test samples for
- Widget Tests - for testing the presence in the tree - the UI elements you are building.
- Golden Tests - test pixel perfect designs
- Unit Tests - test small functionality that has strict input-output requirements. Great Examples may be - calculations, encryption, etc
- BloC Tests - In many cases the business logic is hard to be extracted as Services. Bloc tests - verify expected state of BlocState during/before/after BloC Events.
The app demonstrates Flavor/Environment setup
- Dev
- Prod
included in the following commit also explained in the article here.

