attach method
Observes controller, replacing any previously attached one.
Call this when the driving scroll view changes — on iOS each tab owns its
own scroll view, and UIKit re-resolves contentScrollView(for: .bottom)
on every tab change. Pass null, or use detach, to stop observing.
The minimized state is deliberately left alone: attaching happens during
a build, so changing it here would have to notify listeners mid-build.
Call expand from your onTabSelected if you want the bar to come back
when the user switches tabs.
Implementation
void attach(ScrollController? controller) {
if (_disposed || identical(controller, _scrollController)) return;
// Safe even if the app disposed its ScrollController first —
// ChangeNotifier.removeListener is documented to tolerate that.
_scrollController?.removeListener(_onScroll);
_scrollController = controller;
// A delta measured across two different scroll views is meaningless, and
// would read as one enormous jump.
_baseline = null;
_accumulated = 0.0;
_scrollController?.addListener(_onScroll);
}