Profile Switch Service
Component Detail
Service Layer
medium complexity
mobile
1
Dependencies
1
Dependents
5
Entities
0
Integrations
Description
Core business logic service that manages the active role context for dual-role users. Handles updating the active role in secure local storage, emitting BLoC events to propagate the new role context across the app via Riverpod providers, and ensuring all dependent widgets (home dashboard, navigation items, API request scopes) rebuild with the correct role state. The switch is a purely local operation with no network round-trip required.
profile-switch-service
Responsibilities
- Update the active role in secure local storage upon switch
- Emit BLoC state change events that propagate via Riverpod providers to all dependent widgets
- Resolve and cache available roles at login for instant switching
- Ensure API request scopes and data filtering reflect the newly active role
Interfaces
switchRole(UserRole targetRole)
getActiveRole()
getAvailableRoles()
cacheRolesOnLogin(List<UserRole> roles)
onRoleChanged Stream<UserRole>
isMultiRoleUser()
validateRoleTransition(UserRole from, UserRole to)
Relationships
Related Data Entities (5)
Data entities managed by this component