checkIfYear method Null safety
- TextEditingController textEditingController
Checks if the Value of a TextEditingController is a number within smaller than the current year.
Implementation
static String? checkIfYear(TextEditingController textEditingController) {
final text = textEditingController.text != ""
? int.parse(textEditingController.text)
: 0;
if (text > DateTime.now().year) {
return 'Keine Zeitreise bitte.';
}
// return null if the text is valid
return null;
}