format method

Future<String> format(
  1. String phoneNumberString,
  2. String regionCode
)

Format phoneNumberString or regionCode

Return formatted phone number Throws PlatformException if phoneNumberString is invalid

Implementation

Future<String> format(
  String phoneNumberString,
  String regionCode,
) async {
  final result = await _channel.invokeMapMethod<String, dynamic>(
    'format',
    {
      'string': phoneNumberString,
      'region': regionCode,
    },
  );

  if (result == null) {
    throw PlatformException(
      code: 'FORMAT_FAILED',
      message: 'Formatting the phone number returned null',
    );
  }

  return result['formatted'];
}