CNTabBarRouteObserver class

NavigatorObserver that lets CNTabBar auto-hide while a modal/sheet is presented over its route (Issue #31).

Why it exists: on iOS, CNTabBar is rendered as a native UITabBar inside a Flutter UiKitView. When a Flutter-rendered modal sheet is presented over the same route (e.g. via showCupertinoSheet, showCupertinoModalPopup, or showModalBottomSheet), Flutter's hybrid composition can leave the tab bar's UIView at a higher z-index than the modal's Flutter content — making Material TextFields inside the modal invisible and letting the tab bar bleed through during sheet drags. (Cupertino has the same trade-off: UITabBarController would solve it natively, but that requires owning the whole nav stack.)

What it does: tracks the depth of modal/popup/sheet/dialog routes on every navigator it's attached to, exposed via modalDepth. When depth > 0, CNTabBar (with the default autoHideOnModal: true) swaps its platform view for an empty SizedBox of the same height, mirroring what iOS does natively when a UIViewController presents a full-screen modal over a UITabBarController.

Setup (one line per app):

MaterialApp(
  navigatorObservers: [CNTabBarRouteObserver()],
  // ...
)

or for CupertinoApp:

CupertinoApp(
  navigatorObservers: [CNTabBarRouteObserver()],
  // ...
)

Without this observer registered, CNTabBar still renders correctly — it just won't auto-hide when modals are pushed over it, and you may hit the Issue #31 z-order glitch with Flutter-rendered modal content.

Inheritance

Constructors

CNTabBarRouteObserver()

Properties

hashCode int
The hash code for this object.
no setterinherited
The navigator that the observer is observing, if any.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

didChangeTop(Route topRoute, Route? previousTopRoute) → void
The top most route has changed.
inherited
didPop(Route route, Route? previousRoute) → void
The Navigator popped route.
override
didPush(Route route, Route? previousRoute) → void
The Navigator pushed route.
override
didRemove(Route route, Route? previousRoute) → void
The Navigator removed route.
override
didReplace({Route? newRoute, Route? oldRoute}) → void
The Navigator replaced oldRoute with newRoute.
override
didStartUserGesture(Route route, Route? previousRoute) → void
The Navigator's routes are being moved by a user gesture.
inherited
didStopUserGesture() → void
User gesture is no longer controlling the Navigator.
inherited
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 Properties

anyModalDepth ValueListenable<int>
Read-only listenable of the current sheet/popup/dialog depth (any modal-like route, not just full-screen sheets).
no setter
modalDepth ValueListenable<int>
Read-only listenable of the current modal/sheet depth.
no setter

Static Methods

markAnyModalActive() → void
Manually bump anyModalDepth up by one. Pair with markAnyModalInactive once the modal is dismissed. Useful for non-route-based overlays that NavigatorObserver cannot see — notably Scaffold.showBottomSheet (persistent bottom sheets), which are anchored to Scaffold state instead of the Navigator.
markAnyModalInactive() → void
Pair with markAnyModalActive. Clamps at zero.