# parse static method

Locale parse(

1. String localeString

)

Parses a locale string of the form `"language[-country[-variant]]"`.

This factory method creates a Locale instance from a string representation. The string should follow the standard locale format with components separated by hyphens.

Throws InvalidFormatException if the locale string is empty or invalid.

Example:

    // Parse language only
    final locale1 = Locale.parse('en');
    print(locale1.getLanguageTag()); // Output: "en"

    // Parse language and country
    final locale2 = Locale.parse('fr-CA');
    print(locale2.getLanguage()); // Output: "fr"
    print(locale2.getCountry()); // Output: "CA"

    // Parse language, country, and variant
    final locale3 = Locale.parse('de-DE-Bavaria');
    print(locale3.getVariant()); // Output: "Bavaria"

## Implementation

    static Locale parse(String localeString) => _Locale.parse(localeString);