of<T> static method Null safety

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

Implementation

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