A Flutter application designed to fetch and display a list of countries with their details (name, capital, flag, and country code) from a remote API. This project leverages modern Flutter practices, including clean architecture, BLoC state management, and dependency injection, to deliver a robust and maintainable codebase.
- Fetch country data from a remote API using
Dio. - Display country details (name, capital, flag, code) in a scrollable list.
- Optimized image loading and caching with
cached_network_image. - Local storage for caching with
path_provider. - Comprehensive error handling and loading states with
shimmereffects. - Retry mechanism for failed API requests.
- Routing to the main screen using
GoRouter. - Unit tests for the data layer.
- Networking:
Diofor HTTP requests. - Data Models:
freezedandjson_serializablefor immutable model generation and JSON parsing. - State Management:
flutter_blocfor reactive state management. - Dependency Injection:
get_itfor managing dependencies. - Routing:
GoRouterfor navigation. - Image Optimization:
cached_network_imagefor efficient image loading and caching. - Local Storage:
path_providerfor file system access. - Loading Effects:
shimmerfor animated loading placeholders. - Testing:
flutter_testandmockitofor unit tests and mocking.
This project adheres to Clean Architecture, ensuring separation of concerns across three layers:
- Presentation Layer: Manages UI and state with
CountryBloc(events:FetchCountries, states:CountryLoading,CountryLoaded,CountryError). - Domain Layer: Contains business logic with use cases (e.g.,
GetCountries) and repository interfaces. - Data Layer: Handles API calls, data parsing, and repository implementations.
Dependency injection is powered by get_it, providing a clean and testable dependency management system.
-
Prerequisites:
- Flutter SDK (version 3.16.2 or later recommended).
- Dart SDK (version 3.2.0 or later).
- A code editor (e.g., VS Code or Android Studio).
-
Clone the Repository:
git clone <repository-url> cd flutter_application_1
flutter test