showWithCustomHeader static method
- 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,
- 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,
- Color? itemBackgroundColor,
- Color? itemTextColor,
- 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,
);
}
}