of static method
The state from the closest instance of this class that encloses the given context.
If no ArcaneGridState 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 ArcaneGridState of(BuildContext context) {
final ArcaneGridState? result =
context.findAncestorStateOfType<ArcaneGridState>();
assert(() {
if (result == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary(
'AnimatedReorderableGridViewState.of() called with a context that does not contain a AnimatedReorderableGridViewState.'),
ErrorDescription(
'No AnimatedReorderableGridViewState ancestor could be found starting from the context that was passed to AnimatedReorderableGridViewState.of().',
),
ErrorHint(
'This can happen when the context provided is from the same StatefulWidget that '
'built the AnimatedReorderableGridViewState. '),
context.describeElement('The context used was'),
]);
}
return true;
}());
return result!;
}