I want to check if a TextInputField
has input containing only line breaks or spaces.
In other words, if the input contains anything other than line breaks or spaces.
How can I do that?
CodePudding user response:
I believe the trim
method combined with isEmpty
will be of use here
void main() {
print(checkEmpty('')); // true
print(checkEmpty(' ')); // true
print(checkEmpty('\n\n\n\n')); // true
print(checkEmpty(' z')); // false
print(checkEmpty('\n\t')); // true
}
bool checkEmpty(String val) {
return val.trim().isEmpty;
}