sliverOverlapAbsorberHandleFor static method Null safety

SliverOverlapAbsorberHandle sliverOverlapAbsorberHandleFor(
  1. BuildContext context
)

Returns the SliverOverlapAbsorberHandle of the nearest ancestor NestedScrollView.

This is necessary to configure the SliverOverlapAbsorber and SliverOverlapInjector widgets.

For sample code showing how to use this method, see the NestedScrollView documentation.

Implementation

static SliverOverlapAbsorberHandle sliverOverlapAbsorberHandleFor(BuildContext context) {
  final _InheritedNestedScrollView? target = context.dependOnInheritedWidgetOfExactType<_InheritedNestedScrollView>();
  assert(
    target != null,
    'NestedScrollView.sliverOverlapAbsorberHandleFor must be called with a context that contains a NestedScrollView.',
  );
  return target!.state._absorberHandle;
}