CNCustomSheet class
A custom widget sheet presentation using Flutter overlay rendering.
Use this for sheets with custom Flutter widgets and rich UI that isn't possible with native UIKit rendering. Note that custom widget sheets can be nonmodal but use Flutter overlay instead of native UISheetPresentationController.
When to Use
- Custom layouts with complex Flutter widgets
- Rich UI with segmented controls, toggles, custom components
- Full control over styling and animation
Limitations
- Uses Flutter overlay rendering (not native UIKit)
- Nonmodal behavior implemented via Flutter, not UISheetPresentationController
- May have slightly different performance characteristics than native sheets
Usage
Modal Custom Widget Sheet:
await CNCustomSheet.show(
context: context,
title: 'Format',
items: [
CNCustomSheetItem.widget(
widget: MyCustomWidget(),
dismissOnTap: false,
),
],
isModal: true,
);
Nonmodal Custom Widget Sheet:
await CNCustomSheet.show(
context: context,
title: 'Format',
items: [
CNCustomSheetItem.widget(
widget: MyFormatPanel(),
dismissOnTap: false,
),
],
isModal: false, // Background remains interactive
);
With Custom Header:
await CNCustomSheet.showWithCustomHeader(
context: context,
title: 'Format',
headerTitleWeight: FontWeight.w600,
items: [
CNCustomSheetItem.widget(widget: MyWidget()),
],
);
Constructors
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< CNCustomSheetItem> items = const [], List<CNSheetDetent> detents = const [CNSheetDetent.large], bool prefersGrabberVisible = true, bool isModal = true, double? preferredCornerRadius, Color? itemBackgroundColor, Color? itemTextColor, Color? itemTintColor}) → Future<int?> - Shows a custom widget sheet with Flutter rendering.
-
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, 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}) → Future<int?> - Shows a custom widget sheet with custom header (title + close button).