showWithCustomHeader static method

Future<int?> showWithCustomHeader({
  1. required BuildContext context,
  2. required String title,
  3. String? message,
  4. List<CNCustomSheetItem> items = const [],
  5. List<CNSheetDetent> detents = const [CNSheetDetent.large],
  6. bool prefersGrabberVisible = true,
  7. bool isModal = true,
  8. double? preferredCornerRadius,
  9. double? headerTitleSize,
  10. FontWeight? headerTitleWeight,
  11. Color? headerTitleColor,
  12. double? headerHeight,
  13. Color? headerBackgroundColor,
  14. bool showHeaderDivider = true,
  15. Color? headerDividerColor,
  16. String closeButtonPosition = 'trailing',
  17. String closeButtonIcon = 'xmark',
  18. double? closeButtonSize,
  19. Color? closeButtonColor,
  20. Color? itemBackgroundColor,
  21. Color? itemTextColor,
  22. Color? itemTintColor,
})

Shows a custom widget sheet with custom header (title + close button).

title - Title displayed in the header message - Optional message below the header items - List of items to display detents - Heights at which the sheet can rest prefersGrabberVisible - Whether to show the grabber handle isModal - Whether the sheet blocks background interaction

Header Styling Options: headerTitleSize - Font size for the title headerTitleWeight - Font weight for the title headerTitleColor - Color for the title headerHeight - Height of the header bar headerBackgroundColor - Background color of the header showHeaderDivider - Whether to show divider below header headerDividerColor - Color of the header divider closeButtonPosition - Position of close button: 'leading' or 'trailing' closeButtonIcon - SF Symbol name for close button closeButtonSize - Size of the close button icon closeButtonColor - Color of the close button itemBackgroundColor - Background color for sheet item buttons itemTextColor - Text color for sheet item buttons itemTintColor - Tint color for icons in sheet item buttons

Implementation

static Future<int?> showWithCustomHeader({
  required BuildContext context,
  required String title,
  String? message,
  List<CNCustomSheetItem> items = const [],
  List<CNSheetDetent> detents = const [CNSheetDetent.large],
  bool prefersGrabberVisible = true,
  bool isModal = true,
  double? preferredCornerRadius,
  // Header styling
  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,
  // Item styling
  Color? itemBackgroundColor,
  Color? itemTextColor,
  Color? itemTintColor,
}) async {
  if (isModal) {
    return _showModalSheet(
      context: context,
      title: title,
      message: message,
      items: items,
      prefersGrabberVisible: prefersGrabberVisible,
      preferredCornerRadius: preferredCornerRadius,
      useCustomHeader: true,
      headerTitleSize: headerTitleSize,
      headerTitleWeight: headerTitleWeight,
      headerTitleColor: headerTitleColor,
      headerHeight: headerHeight,
      headerBackgroundColor: headerBackgroundColor,
      showHeaderDivider: showHeaderDivider,
      headerDividerColor: headerDividerColor,
      closeButtonPosition: closeButtonPosition,
      closeButtonIcon: closeButtonIcon,
      closeButtonSize: closeButtonSize,
      closeButtonColor: closeButtonColor,
      itemBackgroundColor: itemBackgroundColor,
      itemTextColor: itemTextColor,
      itemTintColor: itemTintColor,
    );
  } else {
    return _showNonmodalSheet(
      context: context,
      title: title,
      message: message,
      items: items,
      detents: detents,
      prefersGrabberVisible: prefersGrabberVisible,
      preferredCornerRadius: preferredCornerRadius,
      useCustomHeader: true,
      headerTitleSize: headerTitleSize,
      headerTitleWeight: headerTitleWeight,
      headerTitleColor: headerTitleColor,
      headerHeight: headerHeight,
      headerBackgroundColor: headerBackgroundColor,
      showHeaderDivider: showHeaderDivider,
      headerDividerColor: headerDividerColor,
      closeButtonPosition: closeButtonPosition,
      closeButtonIcon: closeButtonIcon,
      closeButtonSize: closeButtonSize,
      closeButtonColor: closeButtonColor,
      itemBackgroundColor: itemBackgroundColor,
      itemTextColor: itemTextColor,
      itemTintColor: itemTintColor,
    );
  }
}