getPhonePrefix function

String? getPhonePrefix(
  1. String phone
)

Returns the local mobile prefix (0XXX) of a phone number, or null if it is not a valid Pakistani mobile number.

Implementation

String? getPhonePrefix(String phone) {
  final digits = normalizePhoneDigits(phone);
  if (digits == null) return null;
  return '0${digits.substring(2, 5)}';
}