Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter: TextField onChange function's conditional

onChanged: (v) async {
  print(EmailValidator.validate(v));
  EmailValidator.validate(v)
      ? () async {
        print('email tureeee');
        }
      : () async {
          print('email not trueee');
        };
},

I have this conditional functions inside the onChange() of the TextField widget. print(EmailValidator.validate(v)); seems to work. However, the conditional function does not execute when condition has been met.

How can I make this work?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

try this:

  onChanged: (v) async {
      print(EmailValidator.validate(v));
      if(EmailValidator.validate(v)){
        print('email tureeee');
      }else{
        print('email not trueee');
      }
    },
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading