I have a form which contains a number of TextFormField similar to this one:
Container(
alignment: Alignment.topCenter,
width: halfMediaWidth-40,
child: MyTextFormField(
hintText: 'Food Name',
validator: (String value) {
if (value.isEmpty) {
return 'Enter food name';
}
return null;
},
onSaved: (String value) {
model.name = value;
},
),
)
In the above widget, the validation is based on its own value. I have a scenario that the validation is to base on more than one TextFormField's value. For example, if the values of two TextFormFields' value are empty, then return error. How can this be accomplished?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…