1

I am using flutter country_code_picker 1.4.0 package to get the dial code, Is there any way to validate international phone number by length.

country_code_picker package

s.am.i
  • 648
  • 5
  • 16

2 Answers2

1

Answer was on comment section, I am mentioning that here,

International phone number input validation

Above package is the only way of I found to validate International phone number flutter

s.am.i
  • 648
  • 5
  • 16
0

You can use regex

NOTE: only 10 digit validate. by below method.

String validateMobile(String value) {
  String pattern = r'(^(?:[+0]9)?[0-9]{10,12}$)';
  RegExp regExp = new RegExp(pattern);

  if (value.length == 0) {
      return 'Please enter mobile number';
  } else if (!regExp.hasMatch(value)) {
      return 'Please enter valid mobile number';
  }

  return null;
} 
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459