Skip to content

Instantly share code, notes, and snippets.

@codxse
Created January 24, 2020 05:44
Show Gist options
  • Save codxse/fb60aaed2e7560e61337a1ad19682127 to your computer and use it in GitHub Desktop.
Save codxse/fb60aaed2e7560e61337a1ad19682127 to your computer and use it in GitHub Desktop.
phone_provider.dart
const OPERATORS = {
"0812": "telkomsel",
"0813": "telkomsel",
"0821": "telkomsel",
"0822": "telkomsel",
"0852": "telkomsel",
"0853": "telkomsel",
"0823": "telkomsel",
"0851": "telkomsel",
"0814": "indosat",
"0815": "indosat",
"0816": "indosat",
"0855": "indoset",
"0856": "indosat",
"0857": "indosat",
"0858": "indosat",
"0895": "tri",
"0896": "tri",
"0897": "tri",
"0898": "tri",
"0899": "tri",
"0881": "smartfren",
"0882": "smartfren",
"0883": "smartfren",
"0884": "smartfren",
"0885": "smartfren",
"0886": "smartfren",
"0887": "smartfren",
"0888": "smartfren",
"0889": "smartfren",
"0817": "xl",
"0818": "xl",
"0819": "xl",
"0859": "xl",
"0877": "xl",
"0878": "xl",
"0838": "axis",
"0831": "axis",
"0832": "axis",
"0833": "axis",
"0999": "bolt",
"0998": "bolt",
};
String headerNumber(String number) {
if (number != null && number.length >= 8) {
if (number.startsWith("+62")) {
return '0' + number.substring(3, 6);
}
if (number.startsWith("62")) {
return '0' + number.substring(2, 5);
}
if (number.startsWith("08")) {
return number.substring(0, 4);
}
if (number.startsWith("8")) {
return '0' + number.substring(0, 3);
}
return number.substring(0, 4);
}
return "unknown";
}
String providerNumber(String numberHeader) {
return OPERATORS[numberHeader];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment