Reputation: 201
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?
Upvotes: 1
Views: 1652
Reputation: 5020
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;
}
Upvotes: 5