decodeByMultiKeys<T> function
T?
decodeByMultiKeys<T>(})
Decodes a value from the given map by matching aganist given set of keys.
If any of the keys matches to a value in the map, the value is returned.
Implementation
T? decodeByMultiKeys<T>(
Map<String, dynamic> map,
List<String> keys, {
T? Function(Object value)? transformer,
T Function()? orElse,
}) {
for (final key in keys) {
if (!map.containsKey(key)) {
continue;
}
final value = map[key];
if (transformer != null) {
return transformer(value);
}
return value;
}
return orElse?.call();
}