showWalletSheet<T> function

Future<T?> showWalletSheet<T>(
  1. BuildContext context, {
  2. required WidgetBuilder builder,
  3. bool isDismissible = true,
  4. bool enableDrag = true,
})

Open builder as a modal bottom sheet and return the route's future (so a picker can return its choice and a caller can chain whenComplete).

Every sheet gets the same frame: scroll-controlled (it grows with large text), inside the safe area, capped at walletSheetMaxWidth on a wide window, and shaped by WalletShapes.sheet.

  • Android and the rest: attached to the bottom edge, top corners rounded, with Material's drag handle.
  • iOS and macOS: inset 8 from the sides and the bottom with all four corners rounded, and a 36 × 5 grabber in colorScheme.outline.

isDismissible and enableDrag pass through. With enableDrag false no handle or grabber is drawn: it would advertise a drag that does nothing (the rescan sheet, which also locks its barrier).

Implementation

Future<T?> showWalletSheet<T>(
  BuildContext context, {
  required WidgetBuilder builder,
  bool isDismissible = true,
  bool enableDrag = true,
}) {
  final theme = Theme.of(context);
  final radius = Radius.circular(WalletShapes.of(context).sheet);
  const constraints = BoxConstraints(maxWidth: walletSheetMaxWidth);
  final cupertino =
      theme.platform == TargetPlatform.iOS ||
      theme.platform == TargetPlatform.macOS;

  if (!cupertino) {
    return showModalBottomSheet<T>(
      context: context,
      isScrollControlled: true,
      useSafeArea: true,
      isDismissible: isDismissible,
      enableDrag: enableDrag,
      showDragHandle: enableDrag,
      constraints: constraints,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.vertical(top: radius),
      ),
      builder: builder,
    );
  }

  // The inset card draws its own fill, so the route's sheet is transparent.
  // The fill is the host's sheet colour when its theme names one.
  final sheetTheme = theme.bottomSheetTheme;
  final fill =
      sheetTheme.modalBackgroundColor ??
      sheetTheme.backgroundColor ??
      WalletColors.of(context).bgCard;
  return showModalBottomSheet<T>(
    context: context,
    isScrollControlled: true,
    useSafeArea: true,
    isDismissible: isDismissible,
    enableDrag: enableDrag,
    showDragHandle: false,
    constraints: constraints,
    backgroundColor: Colors.transparent,
    elevation: 0,
    shape: const RoundedRectangleBorder(),
    builder: (sheetContext) => Padding(
      padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
      child: Material(
        color: fill,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(radius)),
        clipBehavior: Clip.antiAlias,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            if (enableDrag) const _Grabber(),
            Flexible(child: Builder(builder: builder)),
          ],
        ),
      ),
    ),
  );
}