maybeOf method Null safety

SelectionRegistrar? maybeOf(
  1. BuildContext context
)

Gets the immediate ancestor SelectionRegistrar of the BuildContext.

If this returns null, either there is no SelectionContainer above the BuildContext or the immediate SelectionContainer is not enabled.

Implementation

static SelectionRegistrar? maybeOf(BuildContext context) {
  final SelectionRegistrarScope? scope = context.dependOnInheritedWidgetOfExactType<SelectionRegistrarScope>();
  return scope?.registrar;
}