onLifecycleEvent method

void Function() onLifecycleEvent(
  1. void handler(
    1. SessionLifecycleEvent event
    ), [
  2. SessionLifecycleEventType? type
])

Subscribe to all session lifecycle events. Returns an unsubscribe fn.

Implementation

void Function() onLifecycleEvent(
  void Function(SessionLifecycleEvent event) handler, [
  SessionLifecycleEventType? type,
]) {
  if (type != null) {
    final list = _typedLifecycleHandlers.putIfAbsent(type, () => []);
    list.add(handler);
    return () => list.remove(handler);
  }
  _lifecycleHandlers.add(handler);
  return () => _lifecycleHandlers.remove(handler);
}