I had the same problem with lists, now it is Map.
The following syntax is not Dart, as in it does not
Something like this might work as an extension function:
extension MapExtensions on Map {
K getOrNull(T key) {
if (this == null || !this.containsKey(key)) {
return null;
} else {
return this[key];
}
}
K getOrElse(T key, K fallback) {
return this.getOrNull(key) ?? fallback;
}
}
Note: I haven't tested this, but should work.