of static method

The state from the closest instance of this class that encloses the given context.

If no ArcaneList surrounds the given context, then this function will assert in debug mode and throw an exception in release mode.

This method can be expensive (it walks the element tree).

Implementation

static ArcaneListState of(BuildContext context) {
  final ArcaneListState? result =
      context.findAncestorStateOfType<ArcaneListState>();
  assert(() {
    if (result == null) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary(
            'AnimatedReorderableListViewState.of() called with a context that does not contain a AnimatedReorderableListViewState.'),
        ErrorDescription(
          'No AnimatedReorderableListViewState ancestor could be found starting from the context that was passed to AnimatedReorderableListViewState.of().',
        ),
        ErrorHint(
            'This can happen when the context provided is from the same StatefulWidget that '
            'built the AnimatedReorderableListViewState. '),
        context.describeElement('The context used was'),
      ]);
    }
    return true;
  }());
  return result!;
}