selectLogic<T> static method
Internal: Implements the logic for select - use select for normal messages.
Implementation
static T selectLogic<T>(Object choice, Map<Object, T> cases) {
// This will work if choice is a string, or if it's e.g. an
// enum and the map uses the enum values as choices.
var exact = cases[choice];
if (exact != null) return exact;
// If it didn't match exactly, take the toString and
// take the part after the period. We need to do this
// because enums print as 'EnumType.enumName' and periods
// aren't acceptable in ICU select choices.
var stringChoice = '$choice'.split('.').last;
var stringMatch = cases[stringChoice];
if (stringMatch != null) return stringMatch;
var other = cases['other'];
if (other == null) {
throw ArgumentError("The 'other' case must be specified");
}
return other;
}