CNNativeSheet class

A native iOS/macOS sheet presentation using UIKit rendering.

Sheets are modal views that present scoped tasks closely related to the current context. On iOS, sheets can be resizable with detents (medium/large heights). On iPadOS, sheets use page or form sheet styles. On macOS, sheets are always modal and attached to a window.

Nonmodal vs Modal Behavior

Nonmodal Sheets (like Apple Notes formatting sheet):

  • User can interact with background content while sheet is open
  • Can tap, scroll, and select in the parent view
  • Sheet stays open during background interaction
  • Requires: Set isModal: false
  • Uses native UISheetPresentationController with largestUndimmedDetentIdentifier

Modal Sheets (default):

  • Background is dimmed and non-interactive
  • User must dismiss sheet before interacting with background

Usage

Standard Sheet:

await CNNativeSheet.show(
  context: context,
  title: 'Settings',
  items: [
    CNSheetItem(title: 'Brightness', icon: 'sun.max'),
    CNSheetItem(title: 'Appearance', icon: 'moon'),
  ],
  detents: [CNSheetDetent.medium],
);

Nonmodal Sheet:

await CNNativeSheet.show(
  context: context,
  title: 'Format',
  items: [
    CNSheetItem(title: 'Bold', icon: 'bold', dismissOnTap: false),
    CNSheetItem(title: 'Italic', icon: 'italic', dismissOnTap: false),
  ],
  isModal: false,
);

Custom Header Sheet:

await CNNativeSheet.showWithCustomHeader(
  context: context,
  title: 'Format',
  headerTitleWeight: FontWeight.w600,
  items: [
    CNSheetItem(title: 'Bold', icon: 'bold'),
  ],
  isModal: false,
);

Constructors

CNNativeSheet()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

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 onItemSelected(int index)?}) Future<int?>
Shows a native sheet with the given content.
showCustomContent({required BuildContext context, required Widget builder(BuildContext), List<CNSheetDetent> detents = const [CNSheetDetent.large], bool prefersGrabberVisible = true, bool isModal = false, bool barrierDismissible = false}) Future<void>
Shows a sheet with custom Flutter widget content (like Apple Notes formatting sheet).
showWithCustomHeader({required BuildContext context, required String title, String? message, List<CNSheetItem> items = const [], List<CNSheetItemRow> itemRows = const [], List<CNSheetInlineActions> inlineActions = const [], List<CNSheetDetent> detents = const [CNSheetDetent.large], bool prefersGrabberVisible = true, bool isModal = true, bool prefersEdgeAttachedInCompactHeight = false, bool widthFollowsPreferredContentSizeWhenEdgeAttached = false, double? preferredCornerRadius, double? headerTitleSize, FontWeight? headerTitleWeight, Color? headerTitleColor, String headerTitleAlignment = 'left', String? subtitle, double? subtitleSize, Color? subtitleColor, double? headerHeight, Color? headerBackgroundColor, bool showHeaderDivider = true, Color? headerDividerColor, String closeButtonPosition = 'trailing', String closeButtonIcon = 'xmark', double? closeButtonSize, Color? closeButtonColor, Color? itemBackgroundColor, Color? itemTextColor, Color? itemTintColor, void onInlineActionSelected(int rowIndex, int actionIndex)?, void onItemSelected(int index)?, void onItemRowSelected(int rowIndex, int itemIndex)?}) Future<int?>
Shows a native sheet with custom header (title + close button).
showWithCustomHeaderUiKitView({required BuildContext context, required String title, required Widget builder(BuildContext), List<CNSheetDetent> detents = const [CNSheetDetent.large], bool prefersGrabberVisible = true, bool isModal = false, bool prefersEdgeAttachedInCompactHeight = false, bool widthFollowsPreferredContentSizeWhenEdgeAttached = false, double? preferredCornerRadius, double? headerTitleSize, FontWeight? headerTitleWeight, Color? headerTitleColor, double? headerHeight, Color? headerBackgroundColor, bool showHeaderDivider = true, Color? headerDividerColor, String closeButtonPosition = 'trailing', String closeButtonIcon = 'xmark', double? closeButtonSize, Color? closeButtonColor}) Future<void>
Shows a native sheet with custom Flutter widget content using UiKitView.
showWithCustomHeaderWidget({required BuildContext context, required Widget headerBuilder(BuildContext), required Widget contentBuilder(BuildContext), List<CNSheetDetent> detents = const [CNSheetDetent.large], bool prefersGrabberVisible = true, bool isModal = false, bool prefersEdgeAttachedInCompactHeight = false, bool widthFollowsPreferredContentSizeWhenEdgeAttached = false, double? preferredCornerRadius, double? headerHeight, Color? headerBackgroundColor, bool showHeaderDivider = true, Color? headerDividerColor, VoidCallback? onClose}) Future<void>
Shows a native sheet with custom Flutter widget header and content using UiKitView.