GlassTabBarMinimizeController class

Drives GlassTabBar.minimizable's minimize state from scrolling — the equivalent of SwiftUI's .tabBarMinimizeBehavior(_:).

Create one per screen, give the bar both this controller and the scroll view's ScrollController, and dispose it in State.dispose(). The bar reads its minimized state through the controller, so GlassScaffold stays in sync with the bar's real height — including the bottom edge fade and, with extendBody: false, the body inset.

class _HomeState extends State<Home> {
  final _scroll = ScrollController();
  final _minimize = GlassTabBarMinimizeController(
    behavior: GlassBarMinimizeBehavior.onScrollDown,
  );

  @override
  void dispose() {
    _minimize.dispose();
    _scroll.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => GlassScaffold(
        body: ListView.builder(controller: _scroll, ...),
        bottomBar: GlassTabBar.minimizable(
          tabs: _tabs,
          selectedIndex: _index,
          onTabSelected: (i) => setState(() => _index = i),
          minimizeController: _minimize,
          scrollController: _scroll,
          onMinimizedTabTap: _minimize.expand,
        ),
      );
}

This controller borrows the ScrollController it observes and never disposes it — that belongs to the scroll view.

Inheritance

Constructors

GlassTabBarMinimizeController({GlassBarMinimizeBehavior behavior = GlassBarMinimizeBehavior.automatic})
Creates a minimize controller.

Properties

behavior GlassBarMinimizeBehavior
How scrolling maps to minimizing.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
minimized bool
Whether the bar is currently minimized.
no setter
resolvedBehavior GlassBarMinimizeBehavior
behavior with GlassBarMinimizeBehavior.automatic resolved.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
The scroll view currently being observed, if any.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
attach(ScrollController? controller) → void
Observes controller, replacing any previously attached one.
detach() → void
Stops observing the current scroll view. The bar keeps its current state.
dispose() → void
Discards any resources used by the object.
override
expand() → void
Expands the bar.
handleNotification(ScrollNotification notification) → void
Feeds a ScrollNotification to the state machine, for hosts that observe scrolling with a NotificationListener rather than owning a ScrollController.
handleSample(GlassTabBarScrollSample sample) → void
Feeds one scroll sample to the state machine.
minimize() → void
Minimizes the bar.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

kExpandThreshold → const double
Upward travel that re-expands.
kMinimizeThreshold → const double
Downward travel, since the last direction reversal, that reads as intent to minimize.
kMinScrollableExtent → const double
Scrollable extent below which the content is treated as non-scrollable.