parseLocale static method

Locale? parseLocale(
  1. Object? source
)

Implementation

static Locale? parseLocale(Object? source) {
  if (source is! String) return null;
  final parts = source.replaceAll("-", "_").split("_");
  return parts.length == 1
      ? Locale(parts.first)
      : parts.length == 2
          ? Locale(parts.first, parts.last)
          : null;
}