show<T> static method

Future<T?> show<T>({
  1. required BuildContext context,
  2. required Widget child,
  3. String? title,
  4. String? subtitle,
  5. List<PrismSheetAction<T>> actions = const [],
  6. bool isScrollControlled = true,
  7. bool isDismissible = true,
  8. bool useSafeArea = true,
  9. double maxDialogWidth = 460,
  10. Widget? header,
  11. bool showDragHandle = true,
  12. Color? backgroundColor,
})

Shows the adapted surface and resolves with the value passed to Navigator.pop — either from an action, a drag-dismiss (null) or the barrier (null).

Implementation

static Future<T?> show<T>({
  required BuildContext context,
  required Widget child,
  String? title,
  String? subtitle,
  List<PrismSheetAction<T>> actions = const [],
  bool isScrollControlled = true,
  bool isDismissible = true,
  bool useSafeArea = true,
  double maxDialogWidth = 460,
  Widget? header,
  bool showDragHandle = true,
  Color? backgroundColor,
}) {
  final tokens = PrismTokens.of(context);
  final wide = MediaQuery.sizeOf(context).width >= tokens.breakpointCompact;

  if (wide) {
    return showDialog<T>(
      context: context,
      barrierDismissible: isDismissible,
      builder: (dialogContext) => Dialog(
        backgroundColor: backgroundColor,
        clipBehavior: Clip.antiAlias,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(tokens.radiusXl),
        ),
        child: ConstrainedBox(
          constraints: BoxConstraints(maxWidth: maxDialogWidth),
          child: _SheetContent<T>(
            title: title,
            subtitle: subtitle,
            actions: actions,
            header: header,
            showDragHandle: false,
            child: child,
          ),
        ),
      ),
    );
  }

  return showModalBottomSheet<T>(
    context: context,
    isScrollControlled: isScrollControlled,
    isDismissible: isDismissible,
    useSafeArea: useSafeArea,
    showDragHandle: showDragHandle,
    backgroundColor: backgroundColor,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        top: Radius.circular(tokens.radiusXl),
      ),
    ),
    builder: (sheetContext) => _SheetContent<T>(
      title: title,
      subtitle: subtitle,
      actions: actions,
      header: header,
      showDragHandle: false,
      child: child,
    ),
  );
}