'Flutter: TextFormField focus if no data
I have a TextFormField as follows
TextFormField(
readOnly: true,
validator: (v) => (v.isEmpty) ? "Required" : null,
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: sportCenterEditingController,
decoration: ...,
onTap: () async {
var t = showModalAndReturnData();
if (t != null)
sportCenterEditingController.text = sportCenters[i].name;
}),
and even when t == null it goes to focus mode
how can I avoid that? If no data, I would like that it keeps to be unfocused
Solution 1:[1]
Use this code
FocusScope.of(context).unfocus();
sportCenterEditingController.clear();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | akram abdullah |

