addOnAboutToLogOutCallback method
Add a callback to be invoked BEFORE logout while still authenticated.
Use this for cleanup tasks that require auth (e.g., backend FCM unregistration). Callbacks are called with a timeout; failures won't block sign out.
priority determines execution order:
- Higher values execute first (priority 100 runs before priority 0)
- Same priority callbacks execute in parallel
- Default is 0
Best-effort semantics: If callbacks exceed the global timeout, remaining callbacks are abandoned and logout proceeds. Design backend systems to handle orphaned records (e.g., device docs without unregister).
Implementation
@override
void addOnAboutToLogOutCallback(
Future<void> Function() callback, {
int priority = 0,
}) {
_onAboutToLogOutByPriority.putIfAbsent(priority, () => []).add(callback);
}