CNBottomSheet class
Drop-in wrappers for Flutter's modal sheets that opt the CN-widget family into position-aware hide-on-modal behavior.
What it does. When you open a sheet with CNBottomSheet.show (or
CNBottomSheet.showCupertino), a tiny invisible probe is injected into
the sheet's builder. The probe captures the sheet body's live global
rect each frame and publishes it to CNTabBarRouteObserver.topModalRect.
Any CN-widget on the host page consuming ModalHideMixin then only
destroys its native PlatformView IF its own rect geometrically
intersects that published sheet rect.
Why this matters. Without geometry, every CN-widget on the host page has to assume the worst and destroy itself while any sheet is up (the only way to keep the iOS hybrid-composition bleed bug from triggering — Issue #53). That's fine for sheets that cover most of the screen, but for a small 30% sheet it wastefully destroys widgets in your AppBar that are clearly not behind it. The geometry probe gives each CN-widget a way to ask "am I actually behind the sheet?" and only hide when the answer is yes.
API parity. Every parameter of showModalBottomSheet /
showCupertinoSheet is forwarded unchanged. Your builder receives a
regular BuildContext and can return any Flutter widget tree you
want — exactly like the underlying APIs. The probe is invisible: it
neither adds UI nor changes layout.
Fallback for raw sheets. If you use raw showModalBottomSheet
instead of CNBottomSheet.show, topModalRect stays null and
ModalHideMixin falls back to destroying every CN-widget on the host
page (safe but blunt). Migrate your sheet call sites to CNBottomSheet
to get position-aware behavior.
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<
T> ({required BuildContext context, required WidgetBuilder builder, Color? backgroundColor, String? barrierLabel, double? elevation, ShapeBorder? shape, Clip? clipBehavior, BoxConstraints? constraints, Color? barrierColor, bool isScrollControlled = false, double scrollControlDisabledMaxHeightRatio = 9.0 / 16.0, bool isDismissible = true, bool enableDrag = true, bool? showDragHandle, bool useSafeArea = false, RouteSettings? routeSettings, AnimationController? transitionAnimationController, Offset? anchorPoint}) → Future< T?> - Position-aware wrapper for showModalBottomSheet.
-
showCupertino<
T> ({required BuildContext context, required WidgetBuilder pageBuilder, bool enableDrag = true}) → Future< T?> - Position-aware wrapper for showCupertinoSheet — the iOS 26 native-style stacked-card sheet. Same probe injection.
-
showModalPopup<
T> ({required BuildContext context, required WidgetBuilder builder, ImageFilter? filter, Color? barrierColor, bool barrierDismissible = true, bool semanticsDismissible = false, RouteSettings? routeSettings, Offset? anchorPoint}) → Future< T?> - Position-aware wrapper for showCupertinoModalPopup — the iOS action-sheet style popup that animates up from the bottom. Same probe injection. Even though the popup is short, it's still a PlatformView container conflict source, so wrapping is worth it.