of static method

Returns the registery bound to the widget tree. If no registry is bound to the widget tree, this will return the default instance.

More often than not, developers will want to simply utilize the default instance, unless specific parts of an application require highly specialized test steps.

Implementation

static TestStepRegistry of(BuildContext context) {
  TestStepRegistry? result;

  try {
    result = Provider.of<TestStepRegistry>(
      context,
      listen: false,
    );
  } catch (e) {
    // no-op
  }

  return result ?? instance;
}