formatPhoneNumber function
Implementation
String formatPhoneNumber(
{required String countryCode, required String phoneNumber}) {
final String _trimmedPhone = trimWhitespace(phoneNumber);
final String _countryCode =
!countryCode.startsWith('+') ? '+$countryCode' : countryCode;
if (_countryCode == '+1' || _countryCode == '+44' || _countryCode == '+32') {
return '$countryCode$_trimmedPhone';
} else {
final String _phoneNumber = _trimmedPhone.startsWith('0')
? _trimmedPhone.substring(1)
: _trimmedPhone;
return '$_countryCode$_phoneNumber';
}
}