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:
T
is explicitly or implicitly bound todynamic
.- If
T
is notObject
, the DItoken
is 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));
}