container method

Finds the ProviderContainer in the widget tree.

If of is provided, searches for the container within the context of the specified finder.

Implementation

@visibleForTesting
ProviderContainer container({flutter_test.Finder? of}) {
  if (of != null) {
    final element = this.element(of);
    return ProviderScope.containerOf(element, listen: false);
  }

  final scope = widget(flutter_test.find.byType(UncontrolledProviderScope));
  return (scope as UncontrolledProviderScope).container;
}