Add length validator to the notes

This is also checked server side anyway so we better inform the user before
submitting the form
This commit is contained in:
Roland Geider
2021-08-30 20:28:47 +02:00
parent 00caf09d0d
commit 60f7c3ed1b

View File

@@ -224,6 +224,14 @@ class MeasurementEntryForm extends StatelessWidget {
onSaved: (newValue) {
_entryData['notes'] = newValue!;
},
validator: (value) {
const minLength = 1;
const maxLength = 100;
if (value!.isEmpty || value.length < minLength || value.length > maxLength) {
return AppLocalizations.of(context).enterCharacters(minLength, maxLength);
}
return null;
},
),
ElevatedButton(