maybeOf static method
- BuildContext context
The state from the closest instance of this class that encloses the given context, or null if none is found.
Typical usage is as follows:
TwoDimensionalScrollableState? scrollable = TwoDimensionalScrollable.maybeOf(context);
Calling this method will create a dependency on the closest
TwoDimensionalScrollable in the context
. The internal Scrollables
can be accessed through TwoDimensionalScrollableState.verticalScrollable
and TwoDimensionalScrollableState.horizontalScrollable.
Alternatively, Scrollable.maybeOf can be used by providing the desired
Axis to the axis
parameter.
See also:
- TwoDimensionalScrollable.of, which is similar to this method, but asserts if no Scrollable ancestor is found.
Implementation
static TwoDimensionalScrollableState? maybeOf(BuildContext context) {
final _TwoDimensionalScrollableScope? widget = context.dependOnInheritedWidgetOfExactType<_TwoDimensionalScrollableScope>();
return widget?.twoDimensionalScrollable;
}