parse static method

Locale parse(
  1. String code
)

Parses locale codes like 'en', 'ar' or 'en-US'

Implementation

static Locale parse(String code) {
  final parts = code.split('-');
  return parts.length > 1 ? Locale(parts[0], parts[1]) : Locale(parts[0]);
}