toIntlMessageResolver function
Converts resolver
to IntlMessageResolver.
Implementation
IntlMessageResolver? toIntlMessageResolver(Object? resolver) {
if (resolver == null) {
return null;
} else if (resolver is IntlMessageResolver) {
return resolver;
} else if (resolver is String Function(String key)) {
return (k, [p]) => resolver(k);
} else if (resolver is dynamic Function(Object? key)) {
return (k, [p]) => parseString(resolver(k));
} else if (resolver is String Function()) {
return (k, [p]) => resolver();
} else if (resolver is dynamic Function()) {
return (k, [p]) => resolver();
} else if (resolver is Map) {
return (k, [p]) => resolver[k];
} else {
throw ArgumentError('Invalid resolver type: $resolver');
}
}