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.
Asked
Active
Viewed 8,973 times
1
-
Does this answer your question? [How to validate phone numbers using regex](https://stackoverflow.com/questions/123559/how-to-validate-phone-numbers-using-regex) – easeccy Jul 01 '20 at 09:48
-
Thanks, but no it's not the answer..i found the another package – s.am.i Jul 01 '20 at 14:03
-
whats that package? – jzqa Sep 22 '20 at 07:13
-
https://pub.flutter-io.cn/packages/international_phone_input – s.am.i Sep 22 '20 at 17:32
-
Any alternative that support web? – user3808307 Nov 29 '20 at 23:59
2 Answers
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

yamanAppsCoder
- 9
- 2