# Locale.fromMap constructor

Locale.fromMap(

1. Map<String, String?> map

)

Create a Locale from a map.

This factory constructor creates a Locale instance from a Map, which is useful for deserializing from JSON, database records, or API responses.

The map must contain a 'language' key with a non-null value. 'country' and 'variant' keys are optional.

Throws InvalidFormatException if the language key is missing or null.

Example:

    // From a simple map
    final map1 = {'language': 'en', 'country': 'US'};
    final locale1 = Locale.fromMap(map1);
    print(locale1.getLanguageTag()); // Output: "en-US"

    // From JSON
    import 'dart:convert';
    final json = '{"language":"fr","country":"CA","variant":"Quebec"}';
    final map2 = jsonDecode(json) as Map<String, String?>;
    final locale2 = Locale.fromMap(map2);
    print(locale2.getLanguageTag()); // Output: "fr-CA-Quebec"

## Implementation

    factory Locale.fromMap(Map<String, String?> map) {
      if (map['language'] == null) {
        throw InvalidFormatException('Language is required in map');
      }
      return Locale(map['language']!, map['country'], map['variant']);
    }