handleAuthError method

Future<void> handleAuthError()

Handles an INVALID_TOKEN (401) event from the web app.

Contract: if Flourish.onAuthError is provided, the integrator takes over the UI and the default navigation is suppressed. Otherwise the SDK shows AuthErrorPage. (Auth failures are not emitted on the event stream.)

Implementation

Future<void> handleAuthError() async {
  final onAuthError = flourish.onAuthError;
  switch (resolveErrorPresentation(
      isMounted: mounted, hasCallback: onAuthError != null)) {
    case ErrorPresentation.none:
      return;
    case ErrorPresentation.invokeCallback:
      return onAuthError!(context);
    case ErrorPresentation.navigateToFallback:
      return _replaceWithErrorPage(AuthErrorPage(flourish: flourish));
  }
}