get_it
get_it copied to clipboard
`getMaybe` to get object if registered and null otherwise
Sometimes you don't know if what you're looking for is already registered, it is then handy to have a get method that can return null when the registration doesn't exist.
Currently I'm using this workaround:
extension GetItExtension on GetIt {
T? getMaybe<T extends Object>() {
return isRegistered<T>() ? get<T>() : null;
}
}