extractPhoneNumber property

Map<String, String> get extractPhoneNumber

Extracts country code and number from a phone number.

Implementation

Map<String, String> get extractPhoneNumber {
  final match = RegExp(r'^(\+?\d{1,3})?([\d]{10,15})$').firstMatch(this);
  if (match == null) return {};
  return {
    'countryCode': match.group(1) ?? '',
    'number': match.group(2) ?? '',
  };
}