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: TextFormField's enter button to execute GestureDetector Function

TextFormField(
  decoration: InputDecoration(
      prefixIcon: Icon(
        Icons.email_outlined,
        color: Colors.orange,
      ),
      labelText: 'email',),
  onChanged: (v) {
    _emailV = v;
  },
);

GestureDetector(
  onTap: () {},
  child: Container(
      child: Text(
    'emaaail',
  )),
);

I have these two widgets inside the Column(). When a user finishes typing an email address and press done, I want the app to execute GestureDetector - onTap() function.

I’d tried with the context and stuff but did not work as expected. So, I wonder if there is any thing that I can make this works?

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 :

Create a function

// depending on your needs
void onTapFunction(){
   ...
}

add the function to the onTap in the gesture part

GestureDetector(
  onTap: onTapFunction,
  child: Container(
      child: Text(
    'emaaail',
  )),
);

add the function to the onEditingComplete in the TextFormField part

TextFormField(
  decoration: InputDecoration(
      prefixIcon: Icon(
        Icons.email_outlined,
        color: Colors.orange,
      ),
      labelText: 'email',),
  onChanged: (v) {
    _emailV = v;
  },
   onEditingComplete: onTapFunction,
          
);
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