of<T> static method Null safety

SimpleGroupedSwitchState? of<T>(
  1. BuildContext context,
  2. {bool nullOk = false}
)

Implementation

static SimpleGroupedSwitchState? of<T>(BuildContext context,
    {bool nullOk = false}) {
  final SimpleGroupedSwitchState<T>? result =
      context.findAncestorStateOfType<SimpleGroupedSwitchState<T>>();
  if (nullOk || result != null) return result;
  throw FlutterError.fromParts(<DiagnosticsNode>[
    ErrorSummary(
        'SimpleGroupedSwitch.of() called with a context that does not contain an SimpleGroupedSwitch.'),
    ErrorDescription(
        'No SimpleGroupedSwitch ancestor could be found starting from the context that was passed to SimpleGroupedSwitch.of().'),
    context.describeElement('The context used was')
  ]);
}