This application consumes the NASA's "Astronomy Picture of the Day" API and display it's content to users in a fashion manner for Android and iOS.
- 2 screens: a list of images and a detail screen.
- The images list displays the title, date and provide a search field in the top (find by title or date)
- The detail screen has the image and the texts: date, title and explanation
- Work offline
- Support multiple resolutions and sizes
- Pull-to-refresh
- Pagination
- get_it: ^7.6.4
- dio: ^5.3.2
- shared_preferences: ^2.2.1
- cached_network_image: ^3.2.3
- mocktail: ^1.0.0
Here you'll find the application initialization features: AppDependencies (Dependency Injection) and the AppWidget (App Root Widget).
At this layer you'll find the application's core features, such as: constants, environment config, exception handling and the infrastruture layer wich abstracts and implements third part libraries using the Adapter Design Pattern.
Here you'll find the application main functionality, wich deals with the pictures. It was built following the Clean Architecture standard:
- UI
- Presentation
- Domain
- Data
The application environment variables are setted by --dart-define
strategy which allow us to catch environment variables in our Flutter app run or build.
At this development environment you can find --dart-define
values inside flutter_run.sh
script and VsCode launch.json
file, respectively:
flutter run -t lib/main.dart \
--dart-define=API_BASE_URL=https://api.nasa.gov \
--dart-define=API_KEY=ceTiTEfkHDvXK7tSu7hxrrA7hs6fwDYRPajfZ7cz
{
"version": "0.2.0",
"configurations": [
{
"name": "NasaPicturesApp - Dev",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=API_BASE_URL=https://api.nasa.gov",
"--dart-define=API_KEY=ceTiTEfkHDvXK7tSu7hxrrA7hs6fwDYRPajfZ7cz"
]
},
]
}
But for production environments, put sensitive data such as our API_KEY inside the application code is a serious security problem that can be resolved by:
- Set
--dart-define
production values only in the CI environment. - Run code obfuscation algorithms at production build time. (Obfuscate Dart code)
- Install Flutter (The project is using the 3.10.6 version)
- Setup an Android or iOS device / emulator
Clone the project repository:
$ git clone https://github.com/joaovictorgarcia10/nasa_pictures_app.git
Open the project folder and run the following commands:
$ flutter pub get
$ bash flutter_run.sh
You can run the application Unit and Widget Tests by running the flutter_test_coverage.sh
script wich will run all the tests, generate the coverage/lcov.info and the HTML report.
- Note: on macOS you need to have lcov installed on your system (
brew install lcov
).