showCustomContent static method

Future<void> showCustomContent({
  1. required BuildContext context,
  2. required Widget builder(
    1. BuildContext
    ),
  3. List<CNSheetDetent> detents = const [CNSheetDetent.large],
  4. bool prefersGrabberVisible = true,
  5. bool isModal = false,
  6. bool barrierDismissible = false,
})

Shows a sheet with custom Flutter widget content (like Apple Notes formatting sheet).

This creates a non-modal sheet that allows background interaction while displaying custom Flutter widgets as the content. Perfect for formatting toolbars, inspectors, and other auxiliary UI that needs to stay visible while working with the main content.

Key Features:

  • Custom Flutter widget content (full control over UI)
  • Non-modal by default (can interact with background)
  • Native iOS sheet presentation with blur and animations
  • Draggable with detents
  • Optional close button in header

Example:

await CNNativeSheet.showCustomContent(
  context: context,
  builder: (context) => Padding(
    padding: EdgeInsets.all(16),
    child: Column(
      children: [
        Text('Format', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600)),
        SizedBox(height: 16),
        Row(
          children: [
            IconButton(icon: Icon(CupertinoIcons.bold), onPressed: () {}),
            IconButton(icon: Icon(CupertinoIcons.italic), onPressed: () {}),
          ],
        ),
      ],
    ),
  ),
  detents: [CNSheetDetent.custom(280)],
  isModal: false,
);

builder - Function that builds the custom Flutter widget content detents - Heights at which the sheet can rest prefersGrabberVisible - Whether to show the grabber handle isModal - Whether the sheet blocks background interaction (default: false for custom content) barrierDismissible - Whether tapping outside dismisses the sheet (default: false for non-modal)

Implementation

static Future<void> showCustomContent({
  required BuildContext context,
  required Widget Function(BuildContext) builder,
  List<CNSheetDetent> detents = const [CNSheetDetent.large],
  bool prefersGrabberVisible = true,
  bool isModal = false,
  bool barrierDismissible = false,
}) async {
  await showCupertinoModalPopup(
    context: context,
    barrierDismissible: barrierDismissible,
    barrierColor: isModal
        ? CupertinoColors.black.withOpacity(0.4)
        : CupertinoColors.transparent,
    builder: (context) => _CustomContentSheet(
      builder: builder,
      detents: detents,
      prefersGrabberVisible: prefersGrabberVisible,
      isModal: isModal,
    ),
  );
}