idPhoneNumber static method

bool idPhoneNumber(
  1. String number, {
  2. bool isFixedPhone = false,
})

Implementation

static bool idPhoneNumber(String number, {bool isFixedPhone = false}) {
  if (number.isEmpty) {
    return true;
  }
  final RegExp phoneNumberRegExp = RegExp(
    r'^(^\+62|62|^08)(\d{3,4}-?){2}\d{3,4}$',
  );
  final RegExp phoneFixedNumberRegExp = RegExp(
    r'^(^\+62|62|^0)(\d{3,4}-?){2}\d{3,4}$',
  );
  if (isFixedPhone) {
    return phoneFixedNumberRegExp.hasMatch(number);
  }
  return phoneNumberRegExp.hasMatch(number);
}