show<T> static method

Future<T?> show<T>(
  1. BuildContext context, {
  2. required GlobalKey<State<StatefulWidget>> avatarKey,
  3. required GlobalKey<State<StatefulWidget>> panelKey,
})

Displays an AccountsSwitcherView via separate RawDialogRoute.

Implementation

static Future<T?> show<T>(
  BuildContext context, {
  required GlobalKey avatarKey,
  required GlobalKey panelKey,
}) async {
  final style = Theme.of(context).style;

  final route = RawDialogRoute<T>(
    barrierColor: style.barrierColor.withValues(alpha: .1),
    barrierDismissible: true,
    pageBuilder: (_, _, _) =>
        AccountsSwitcherView(avatarKey: avatarKey, panelKey: panelKey),
    fullscreenDialog: true,
    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
    transitionDuration: const Duration(milliseconds: 300),
    transitionBuilder: (_, Animation<double> animation, _, Widget child) {
      return AnimatedBuilder(
        animation: animation,
        builder: (context, child) {
          return BackdropFilter(
            filter: ui.ImageFilter.blur(
              sigmaX: animation.value * 10,
              sigmaY: animation.value * 10,
            ),
            child: FadeTransition(opacity: animation, child: child),
          );
        },
        child: child,
      );
    },
  );

  router.obscuring.add(route);

  try {
    return await Navigator.of(context, rootNavigator: true).push<T>(route);
  } finally {
    router.obscuring.remove(route);
  }
}