The app uses Dio as its HTTP client, configured inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/andrespaul123/micole-flutter/llms.txt
Use this file to discover all available pages before exploring further.
lib/core/dio/dio_client.dart. A single Dio instance is created in main() and injected into every repository via the constructor, so the entire app shares one client with consistent base options and interceptors.
DioClient.create()
The static factory method that bootstraps the configuredDio instance:
BaseOptions breakdown
| Option | Value | Purpose |
|---|---|---|
baseUrl | http://192.168.100.206:8000/api | All repository paths are relative to this root |
connectTimeout | 10 seconds | Maximum time to establish a socket connection |
receiveTimeout | 15 seconds | Maximum time to receive the full response body |
sendTimeout | 10 seconds | Maximum time to upload the request body |
Content-Type | application/json | Tells the server to expect JSON |
Accept | application/json | Requests JSON responses from the server |
Request interceptor
Before every request, the interceptor reads the session token fromSecureStorage and attaches it as a Bearer header:
SecureStorage.getToken() reads from FlutterSecureStorage on mobile and from SharedPreferences on web, so the same interceptor code works across all platforms:
Error interceptor
When the API returns a401 Unauthorized response, the interceptor wipes the local session and redirects the user to the login screen without requiring a BuildContext:
SecureStorage.clear() removes the token, role, name, and email from storage (both secure storage and SharedPreferences depending on platform). After clearing, the error is still forwarded via handler.next(error) so that individual ViewModels can display an appropriate message if needed.
Debug logging
In debug builds every outgoing request prints its HTTP method and path to the console:kDebugMode so no logging overhead or sensitive path information is included in release builds.
Updating the base URL
Openlib/core/dio/dio_client.dart and replace the baseUrl value:
--dart-define:
redirectToLogin() and BuildContext-free navigation
The
redirectToLogin() helper uses a late module-level GoRouter variable to navigate without needing a BuildContext. This is necessary because the Dio interceptor runs outside the widget tree.lib/core/router/app_router.dart:
_routerInstance is assigned when createRouter() is called in main(), which always happens before any network request can be made. The redirectToLogin() function is then imported and called directly from the Dio error interceptor.