Mi Cole uses the Provider package for state management. Every feature exposes aDocumentation 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.
ChangeNotifier ViewModel that owns the loading state, error messages, and data lists for that domain. Widgets subscribe to ViewModels using context.watch<T>() and trigger actions via context.read<T>().
Architecture pattern
Provider registration
All providers are registered as a flatMultiProvider list in main(). The Dio instance and most ViewModels are created before runApp() so they are available immediately:
AuthViewModel in depth
AuthViewModel is the most important ViewModel in the app. It is the source of truth for authentication state and drives the router redirect logic.
Key properties
| Property | Type | Description |
|---|---|---|
isLoggedIn | bool | true when token != null |
role | String? | First element of user.roles; drives menu & redirect |
user | Users? | Logged-in user object (id, name, email, token, roles) |
loading | bool | true while a login/register request is in flight |
loginError | String? | Human-readable error from the last failed login attempt |
loadSession()
loadSession() is awaited in main() before runApp(). It reads the persisted session from SecureStorage and reconstructs the Users object so that isLoggedIn and role are accurate when GoRouter evaluates its initial redirect:
Consuming providers in widgets
Usecontext.watch<T>() when you want the widget to rebuild on every change, and context.read<T>() when you only need to call a method without subscribing to updates.
Provider.of<T>(context) form (equivalent to watch) or Provider.of<T>(context, listen: false) (equivalent to read).
Example: HomeDashboard consuming two ViewModels
HomeDashboard uses Provider.of to read both AuthViewModel and TenantViewModel and renders role-specific content:
ChangeNotifierProvider.value vs create:
ChangeNotifierProvider.value(value: vm)
Use when the
ChangeNotifier is created outside the widget tree (i.e. before runApp()). The provider does not manage the object’s lifecycle — you are responsible for disposing it if needed. AuthViewModel is the only instance of this pattern in Mi Cole because it must exist before the router is initialised.ChangeNotifierProvider(create: (_) => …)
Use for all other ViewModels. Provider creates the object lazily on first access and disposes it automatically when the owning widget is removed from the tree. This is the standard pattern for all feature ViewModels.