This project demonstrates how to use dart_acdc to build a production-ready HTTP client for the Google Tasks API and public APIs.
It showcases the "Zero-Config" philosophy: simply build a Dio instance with dart_acdc and get free logging, error handling, caching, and token management.
- Authentication:
- Authenticates with Google using Implicit Flow (via
flutter_web_auth_2). - Securely stores tokens using
SecureTokenProvider. - Automatically injects Bearer tokens into requests.
- Authenticates with Google using Implicit Flow (via
- Smart Caching:
- Authenticated Cache: Caches your private task lists (user-isolated).
- Public API Cache: Demonstrates standard
max-agecaching usinghttpbin.org/cache. - Force Refresh: Bypass cache on demand.
- Observability:
- Real-time request/response logging in the UI with redaction of sensitive data.
To run the Google Tasks demo, you must have a Google Cloud Project with the Google Tasks API enabled.
- Create a Client ID for Web Application in Google Cloud Console.
- Add
http://localhost:3000(or your app's origin) to Authorized-JavaScript Origins. - Add
http://localhost:3000/callback.htmlto Authorized Redirect URIs. - Copy your Client ID.
Note: The Public API feature (HttpBin) does not require authentication setup.
- Ensure you have
http://localhost:3000configured in Google Cloud (for Google Auth). - Run with the fixed port:
cd example
flutter run -d chrome --web-port 3000- Enter your Client ID in the app's UI to login.
You can test the public API caching feature without logging in. Just click "Fetch Public (Max-Age: 10s)" in the UI.
(Note: Mobile setup requires deep linking configuration. See AndroidManifest.xml and Info.plist).
- Configure Android/iOS deep links for
dartacdc://callback. - Run
flutter run.