addOnAboutToLogOutCallback abstract method

void addOnAboutToLogOutCallback(
  1. Future<void> callback(), {
  2. int priority = 0,
})

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

void addOnAboutToLogOutCallback(
  Future<void> Function() callback, {
  int priority = 0,
});