parseList method

Future<Map<String, PhoneNumber>> parseList(
  1. List<String> phoneNumberStrings, {
  2. String? regionCode,
})

Returns a Map with the keys set to each item in phoneNumberStrings and the value to the corresponding result of a parse operation for that item. See parse for details.

Implementation

Future<Map<String, PhoneNumber>> parseList(
  List<String> phoneNumberStrings, {
  String? regionCode,
}) async {
  final result = await _channel.invokeMapMethod<String, dynamic>(
    'parse_list',
    {
      'strings': phoneNumberStrings,
      'region': regionCode,
    },
  );

  if (result == null) {
    throw PlatformException(
      code: 'PARSE_FAILED',
      message: 'Parsing the phone numbers returned null',
    );
  }

  return result.map(
    (key, value) => MapEntry(
      key,
      PhoneNumber.fromJson(Map<String, dynamic>.from(value)),
    ),
  );
}