handleAuthenticated abstract method
Public handler for auth state changes. Called when user authenticates.
This method can be passed to AuthService constructor for race-free initialization, ensuring callbacks are registered before Firebase listeners attach.
Usage
// Race-free initialization pattern:
final deviceService = DeviceServiceImpl();
final auth = AuthServiceImpl(
firebaseApp: app,
onAuthenticatedCallbacks: [deviceService.handleAuthenticated],
);
await deviceService.initialize(authService: auth);
Defensive Behavior
- Returns immediately if
uidis null (shouldn't happen in practice) - Logs a warning if called before initialize (indicates ordering bug)
- Uses pending payload fallback for graceful degradation
Parameters
uid: The authenticated user's ID, or null on logout.
Implementation
Future<void> handleAuthenticated(String? uid);