getNetwork function

NetworkName getNetwork(
  1. String phone
)

Detects the mobile network for a Pakistani phone number from its prefix.

Returns the network the prefix was originally allocated to. Because of Mobile Number Portability (MNP) and operator mergers, the current carrier may differ. Returns NetworkName.unknown if the number is not a valid Pakistani mobile number.

Implementation

NetworkName getNetwork(String phone) {
  final prefix = getPhonePrefix(phone);
  if (prefix == null) return NetworkName.unknown;
  return _prefixMap[prefix] ?? NetworkName.unknown;
}