get method Null safety
- String key
Gets a persistent record value given its key
.
Returns default value indicated in defaulValues
if the actual value
doesn't exist or its runtime type value differs from the default one.
If the key doesn't exists and its default value is not specified, returns
null
.
Implementation
dynamic get(String key) {
final contextKey = '$prefix:$key';
final notifierValue = notifier!.value;
if (defaultValues.containsKey(key)) {
if (!notifierValue.containsKey(contextKey) ||
notifierValue[contextKey].runtimeType !=
defaultValues[key].runtimeType) {
return defaultValues[key];
} else {
return notifierValue[contextKey];
}
} else {
if (notifierValue.containsKey(contextKey)) {
return notifierValue[contextKey];
} else {
return null;
}
}
}