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
  • 378
  • 2
  • 10

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
  • 378
  • 2
  • 10
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
  • 704,970
  • 168
  • 1,303
  • 1,425