provideTypeOptional<T extends Object> method
Finds and returns an object instance provided for a type token.
Unlike provideType, null is returned if a provider is not found.
A runtime assertion is thrown in debug mode if:
Tis explicitly or implicitly bound todynamic.- If
Tis notObject, the DItokenis not the same asT.
Implementation
@nonVirtual
T? provideTypeOptional<T extends Object>(Type token) {
// See provideType.
assert(T != dynamic, 'Returning a dynamic is not supported');
return unsafeCast(get(token, null));
}