show<T> static method

Future<T?> show<T>({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. NesDialogFrame frame = const NesBasicDialogFrame(),
})

A shortcut method that can be used to show this dialog.

Implementation

static Future<T?> show<T>({
  required BuildContext context,
  required WidgetBuilder builder,
  NesDialogFrame frame = const NesBasicDialogFrame(),
}) {
  final nesTheme = context.nesThemeExtension<NesTheme>();

  final scaling = NesFixedViewportScaling.maybeOf(context);

  return showGeneralDialog<T>(
    context: context,
    barrierColor: Colors.transparent,
    transitionBuilder: (context, animation, secondaryAnimation, child) {
      return MouseRegion(
        cursor: nesTheme.basicCursor,
        child: SizedBox.expand(
          child: DecoratedBox(
            decoration: const BoxDecoration(
              image: NesCheckeredDecoration(),
            ),
            child: Transform.scale(
              scaleY: animation.value,
              child: child,
            ),
          ),
        ),
      );
    },
    pageBuilder: (_, __, ___) {
      final dialog = NesDialog(
        frame: frame,
        child: builder(context),
      );

      if (scaling != null) {
        return Transform.scale(
          scale: scaling,
          child: dialog,
        );
      }

      return dialog;
    },
  );
}