parsePhoneNumber method
Accepts a formatted phoneNumber
returns a String of phoneNumber
with the dialCode replaced with an empty String
Implementation
String parsePhoneNumber(String? phoneNumber) {
if (dialCode.length > 4) {
if (isPartOfNorthAmericanNumberingPlan(dialCode)) {
String northAmericaDialCode = '+1';
String countryDialCodeWithSpace = northAmericaDialCode +
' ' +
dialCode.replaceFirst(northAmericaDialCode, '');
return phoneNumber!
.replaceFirst(countryDialCodeWithSpace, '')
.replaceFirst(separatorChars, '')
.trim();
}
}
return phoneNumber!.replaceFirst(dialCode, '').trim();
}