get<T> method

T get<T>()

Retrieves the nearest DependencyProvider of type T from the widget tree.

This method uses the DependencyProvider.of method to find the dependency and returns the found DependencyProvider.

Example usage:

final myDependency = context.get<MyDependency>().dependency;

Implementation

T get<T>() {
  // Use DependencyProvider.of to find the nearest DependencyProvider of type T
  final dep = DependencyProvider.of<T>(this).dependency;
  return dep;
}