This is a Flutter application that displays images from NASA's "Astronomy Picture of the Day" (APOD) website. The app showcases the use of Flutter with Clean Architecture, state management with Cubit, dependency injection with GetIt, and offline support with Hive for caching.
- Two Screens: A list of images and a detail screen for each image.
- Search Functionality: Search for images by title or date.
- Offline Support: The app can function without an internet connection by using cached data.
- Pull-to-Refresh: Refresh the list of images by pulling down.
- Error Handling: Displays error messages when something goes wrong.
-
Clone the repository:
git clone https://github.com/matheusalves753/astro_snap.git cd astro_snap
-
Install dependencies:
flutter pub get
-
Run the app:
flutter run
To use the NASA API, you need to get an API key from NASA API.
The project follows the principles of Clean Architecture. Here is a brief overview of the project structure:
lib
└── src
├── data
│ ├── datasources
│ ├── models
│ ├── repositories
├── domain
│ ├── entities
│ ├── repositories
│ ├── usecases
├── infrastructure
├── presentation
- Flutter: UI toolkit for building natively compiled applications for mobile, web, and desktop from a single codebase.
- GetIt: A simple service locator for Dart and Flutter projects.
- Cubit: A lightweight state management solution, part of the flutter_bloc package.
- Freezed: Code generation for unions/pattern-matching/copy in Dart.
- Hive: A lightweight and blazing fast key-value database written in pure Dart.
- Connectivity Plus: A Flutter plugin for discovering the state of the network (WiFi & mobile/cellular) connectivity.
- Intl: Provides internationalization and localization facilities.
- Auto Route: Declarative routing for Flutter.
- Cached Network Image: A flutter library to show images from the internet and keep them in the cache directory.
- Path Provider: A Flutter plugin for finding commonly used locations on the filesystem.
- Flutter Cache Manager: Generic cache manager for flutter.
The app uses Hive for caching data locally, allowing it to function without an internet connection. The connectivity status is checked using the connectivity_plus
package. If there is no internet connection, the app retrieves data from the local cache.
Note: The pagination feature is not implemented due to limitations in the NASA API, which does not support pagination parameters.
To run the tests for this project, use the following command:
flutter test
For any inquiries or feedback, please contact [[email protected]].