Reputation: 3292
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?
Upvotes: 0
Views: 280
Reputation: 406
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,
);
Upvotes: 2
Reputation: 154
You should try Inkwell() instead of GestureDetector() if you only want the ontap function to be executed;
Inkwell(
onTap: () {
//write your function
},
child: Container(
child: Text(
'emaaail',
)),
);
)
Upvotes: 1