caseByType<TOptionType, TValue> function
TValue?
caseByType<TOptionType, TValue>(])
Limitation, Map<Type, TValue> - Type can be any type!
Implementation
TValue? caseByType<TOptionType, TValue>(
TOptionType selectedOption,
Map<Type, TValue> branches, [
TValue? defaultValue = null,
]) {
var type = selectedOption.runtimeType;
if (branches.keys
.where((x) => //
x == type)
.isEmpty) {
return defaultValue;
}
var key = branches.keys.where((x) => x == type).first;
var value = branches[key];
return value;
}