Reputation: 311
Hy guys. TextFormField flutter web once you click into the form, cursor start blinking awaiting input. What I want to do is if I click outside this form the cursor will gone and focus on the form closed.
this is my code as:
TextFormField(
style: TextStyle(
color: Theme.of(context).iconTheme.color,fontSize: 13,
),
decoration: InputDecoration(
contentPadding: new EdgeInsets.all(8),
border: InputBorder.none,
prefixIcon: Icon(
Icons.search,
color: Theme.of(context).iconTheme.color,
),
hintStyle: TextStyle(
color: Theme.of(context).iconTheme.color,fontSize: 13),
filled: true,
fillColor: Color(0xffe7e7e7),
hintText: 'Cerca da Nome - ID - EAN'),
),
Upvotes: 0
Views: 992
Reputation: 1452
Wrap your Scaffold with a GestureDetector() and set unfocus() to the current FocusScopeNode
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if(!currentFocus.hasPrimaryFocus) {
currentFocus.focusedChild.unfocus();
}
},
child: Scaffold()
);
}
Upvotes: 1