I'm making a custom TextFormField Widget which will be used multiple times. How do I validate a single TextFormField without validating any other TextFormField that are in the same list/row/column.
Widget timeTextField (TextEditingController controller){
return TextFormField(
controller: controller,
validator: (String userInput){
if(userInput.isEmpty){return 'Need to input time';}
},
onFieldSubmitted: (String userInput){
setState(() {
debugPrint(userInput);
controller.text = "amout";
debugPrint(controller.text);
});
},
);
}
It validates when the user presses submit on the keyboard, if the TextFormField is empty it sends a validation error only to that TextFormField which the user pressed submit on.