BaseNativeSheet class
BaseNativeSheet - Cross-platform native sheet with iOS UISheetPresentationController support
Uses native iOS UISheetPresentationController for true native sheet presentation with built-in liquid glass effects and native rendering. Uses Material Design bottom sheets for Android and other platforms.
Features:
- Native iOS sheet presentation via UISheetPresentationController
- Resizable sheets with detents (medium, large, custom heights)
- Nonmodal sheet support for background interaction
- Custom header with title and close button
- Material Design bottom sheet fallback
- Apple HIG compliant sheet behavior
Apple HIG implementation:
- Modal and nonmodal sheet presentations
- Grabber handle for resizable sheets
- Edge attachment in compact height
- Preferred corner radius customization
- Native item rendering with SF Symbols
Example usage:
// Standard modal sheet
final selectedIndex = await BaseNativeSheet.show(
context: context,
title: 'Settings',
items: [
CNSheetItem(title: 'Brightness', icon: 'sun.max'),
CNSheetItem(title: 'Appearance', icon: 'moon'),
],
detents: [CNSheetDetent.medium],
);
// Nonmodal sheet (allows background interaction)
await BaseNativeSheet.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 BaseNativeSheet.showWithCustomHeader(
context: context,
title: 'Format',
headerTitleWeight: FontWeight.w600,
items: [
CNSheetItem(title: 'Bold', icon: 'bold'),
],
isModal: false,
);
Updated: 2024.10.25 - Renamed from BaseCNNativeSheet for consistency
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- BaseStatelessWidget
- BaseNativeSheet
Constructors
- BaseNativeSheet({Key? key, BaseParam? baseParam})
-
Creates a base native sheet wrapper
const
Properties
- baseParam → BaseParam?
-
Personalization parameters, gets platform parameters first, then mode parameters
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
beforeBuild(
BuildContext context) → void -
Called before build
inherited
-
beforeBuildByCupertino(
BuildContext context) → void -
Called before buildByCupertino
inherited
-
beforeBuildByCupertinoNative(
BuildContext context) → void -
Called before buildByCupertinoNative (native iOS implementation)
inherited
-
beforeBuildByMaterial(
BuildContext context) → void -
Called before buildByMaterial
inherited
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
buildByCupertino(
BuildContext context) → Widget - build on cupertino mode (Flutter implementation)
-
buildByCupertinoNative(
BuildContext context) → dynamic -
build on cupertino mode with native iOS components (cupertino_native package)
This is called when baseParam.nativeIOS = true
Default implementation falls back to buildByCupertino()
inherited
-
buildByMaterial(
BuildContext context) → Widget - build on material mode
-
commonBuild(
BuildContext context, BaseParam? baseParam) → dynamic -
inherited
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
getBuildMode(
BaseParam? baseParam) → WidgetBuildMode -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
-
valueOf(
String key, dynamic value) → dynamic -
inherited
-
valueOfBaseParam(
BaseParam? baseParam, String key, dynamic value) → dynamic -
No reflection available in Dart
First get value from platform, then from mode, finally from value itself
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)?, BaseParam? baseParam}) → Future<int?> - Shows a native sheet with the given content.
-
showWithCustomHeader(
{required BuildContext context, required String title, String? subtitle, double? subtitleSize, Color? subtitleColor, 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, void onInlineActionSelected(int rowIndex, int actionIndex)?, void onItemSelected(int index)?, void onItemRowSelected(int rowIndex, int actionIndex)?, double? headerTitleSize, FontWeight? headerTitleWeight, Color? headerTitleColor, String headerTitleAlignment = 'left', 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, BaseParam? baseParam}) → Future<int?> - Shows a native sheet with custom header (title + close button).