providerOf<T extends QudsProvider> static method

T? providerOf<T extends QudsProvider>(
  1. BuildContext context
)

Return the instance of the required QudsProvider, the instance must be included in the providers list

Implementation

static T? providerOf<T extends QudsProvider>(BuildContext context) {
  var app = context.dependOnInheritedWidgetOfExactType<QudsApp>();
  assert(app != null, 'There is no QudsApp initialized');
  for (var p in app!.controller.providers) {
    if (p is T) {
      return p;
    }
  }

  return null;
}