PhoneNumber.fromJson constructor

PhoneNumber.fromJson(
  1. Map<String, dynamic> map, {
  2. String? key,
})

Returns a valid PhoneNumber object.

If key is null PhoneNumber.key is used to get it's corresponding value in map.

Throws InvalidValueException if map's value is not a valid phone number.

Implementation

factory PhoneNumber.fromJson(Map<String, dynamic> map, {String? key}) {
  final flatMap = flattenMap(map);
  final value = flatMap[key ?? PhoneNumber.key].toString();

  return PhoneNumber(value);
}