show static method

Future<int?> show({
  1. required BuildContext context,
  2. String? title,
  3. String? message,
  4. List<CNSheetItem> items = const [],
  5. List<CNSheetDetent> detents = const [CNSheetDetent.large],
  6. bool prefersGrabberVisible = true,
  7. bool isModal = true,
  8. bool prefersEdgeAttachedInCompactHeight = false,
  9. bool widthFollowsPreferredContentSizeWhenEdgeAttached = false,
  10. double? preferredCornerRadius,
  11. Color? itemBackgroundColor,
  12. Color? itemTextColor,
  13. Color? itemTintColor,
  14. void onItemSelected(
    1. int index
    )?,
  15. BaseParam? baseParam,
})

Shows a native sheet with the given content.

Uses native UISheetPresentationController for rendering on iOS/iPadOS/macOS. Falls back to Material bottom sheet on other platforms.

context - Build context for presentation title - Optional title for the sheet (displays in content area with close button) message - Optional message below the title items - List of items to display in the sheet detents - Heights at which the sheet can rest (iOS only, defaults to large) prefersGrabberVisible - Whether to show the grabber handle (iOS only) isModal - Whether the sheet is modal (blocks interaction with parent view). Default is true. Set to false for nonmodal sheets that allow background interaction (iOS/iPadOS only, always modal on macOS/visionOS/watchOS). prefersEdgeAttachedInCompactHeight - Whether sheet attaches to edge in compact height widthFollowsPreferredContentSizeWhenEdgeAttached - Whether width follows preferred content size preferredCornerRadius - Custom corner radius for the sheet itemBackgroundColor - Background color for sheet item buttons (default: clear) itemTextColor - Text color for sheet item buttons (default: system label) itemTintColor - Tint color for icons in sheet item buttons (default: system tint) baseParam - Platform override parameter

Implementation

static Future<int?> show({
  required BuildContext context,
  String? title,
  String? message,
  List<CNSheetItem> items = const [],
  List<CNSheetDetent> detents = const [CNSheetDetent.large],
  bool prefersGrabberVisible = true,
  bool isModal = true,
  bool prefersEdgeAttachedInCompactHeight = false,
  bool widthFollowsPreferredContentSizeWhenEdgeAttached = false,
  double? preferredCornerRadius,
  Color? itemBackgroundColor,
  Color? itemTextColor,
  Color? itemTintColor,
  void Function(int index)? onItemSelected,
  BaseParam? baseParam,
}) async {
  final param = baseParam ?? BaseParam();

  // Determine if we should use Cupertino or Material implementation
  final useCupertino = param.forceUseCupertino ||
                      (!param.forceUseMaterial && _shouldUseCupertino());

  if (useCupertino) {
    // Delegate directly to cupertino_native's CNSheet
    return await CNSheet.show(
      context: context,
      title: title,
      message: message,
      items: items,
      detents: detents,
      prefersGrabberVisible: prefersGrabberVisible,
      isModal: isModal,
      prefersEdgeAttachedInCompactHeight: prefersEdgeAttachedInCompactHeight,
      widthFollowsPreferredContentSizeWhenEdgeAttached: widthFollowsPreferredContentSizeWhenEdgeAttached,
      preferredCornerRadius: preferredCornerRadius,
      itemBackgroundColor: itemBackgroundColor,
      itemTextColor: itemTextColor,
      itemTintColor: itemTintColor,
      onItemSelected: onItemSelected,
    );
  } else {
    return await _NativeSheetMaterial.show(
      context: context,
      title: title,
      message: message,
      items: items,
      detents: detents,
      prefersGrabberVisible: prefersGrabberVisible,
      isModal: isModal,
      prefersEdgeAttachedInCompactHeight: prefersEdgeAttachedInCompactHeight,
      widthFollowsPreferredContentSizeWhenEdgeAttached: widthFollowsPreferredContentSizeWhenEdgeAttached,
      preferredCornerRadius: preferredCornerRadius,
      itemBackgroundColor: itemBackgroundColor,
      itemTextColor: itemTextColor,
      itemTintColor: itemTintColor,
      onItemSelected: onItemSelected,
    );
  }
}