Awesome
Coronavirus REST API Flutter Course
Source code for my Coronavirus REST API Flutter Course on Teachable.
This repository has one commit for each course lesson that contains code changes.
Each commit has a corresponding tag, which is named with the same numbering used in the course: sectionNumber.lessonNumber
).
Note about files in .gitignore
The following files contain API keys and are not included in the repository:
.vscode/settings.json
lib/app/services/api_keys.dart
When cloning this project, make sure to define your local copies according to the instructions given in the course.
Course Curriculum
Section 1: Intro to REST and the nCoV 2019 REST API
- RESTful APIs: The Basics
- The nCoV 2019 Coronavirus API: Setup instructions, API Keys and Access Tokens
- REST Client for VS Code: Initial setup & sending requests
- REST Client: Using Environment Variables and excluding sensitive data with .gitignore
- REST Client: Adding the remaining requests
Section 2: Building an API Service with the Dart http package
- App Architecture Overview
- Installing the http package
- Saving the API key + GitHub source code + the Error Lens extension
- The API class
- The APIService class: requesting an access token
- Parsing the http response and retrieving the access token
- Using the API Service to show the access token
- Adding the remaining endpoints to the API class
- Requesting and parsing data from the remaining endpoints
- Using the APIService class to show endpoint data
- Recap on the APIService class
Section 3: Building a Data Repository and creating the basic UI
- The Data Repository
- Loading and refreshing the access token when needed
- Adding a Provider for the DataRepository
- Creating a basic dashboard UI
- Creating a custom card widget to show endpoint data
- Loading the initial endpoint data from the API
- Adding a refresh indicator
Section 4: Loading data from multiple endpoints and polishing the UI
- Loading data from multiple endpoints with Future.wait
- The EndpointsData class
- Improving the DataRepository class with generics and function arguments
- Showing all the cards
- Adding the icon assets to the project
- Update the cards layout, image and color
Section 5: Date formatting and reading the last updated date from the server
- Showing when the data was last updated: client vs server approach
- Parsing date information from the API response data
- Creating a new data model to hold the date and value from the API
- Showing the last updated date in the UI
- Formatting dates with the intl package
- Add thousands' separators with the NumberFormat class
Section 6: Error handling and caching data with Shared Preferences
- Error handling overview, and understanding the call stack
- Showing an alert dialog to the user
- Completing the error handling code
- Introduction to data persistence with Shared Preferences
- Writing a DataCacheService
- Integrating the DataCacheService in the DataRepository
- Injecting the DataCacheService in main.dart
- Hot fix: The getter 'date' was called on null
- Conclusion & next steps