Search code examples
flutterdartmobile-application

How to validate for a empty field for a mobile no in flutter?


How do I validate for a empty phone number field in a form in flutter without using any extra packages or dependencies?


Solution

  • The easiest way is to check the conditions before printing/returning the values. Check for the following conditions before printing/returning the values. Pass the following conditions in the onPressed.

        if(value == null || value.length <10)
          print('Enter valid input');
        else
          print(value);