The syntax of String.isNotEmpty property is:
bool isNotEmpty
This isNotEmpty property of String checks whether this string is not empty.
String.isNotEmpty returns value of type bool
.
In this example,
str
with the value 'Hello'.isNotEmpty
property of the string.true
.void main() {
String str = 'Hello';
bool notEmpty = str.isNotEmpty;
print('Is $str not empty: $notEmpty');
}
Is Hello not empty: true
In this example,
str
with the value 'ABCDEF'.isNotEmpty
property of the string.true
.void main() {
String str = 'ABCDEF';
bool notEmpty = str.isNotEmpty;
print('Is $str not empty: $notEmpty');
}
Is ABCDEF not empty: true
In this example,
str
with the value '' (empty string).isNotEmpty
property of the string.false
.void main() {
String str = ''; // Empty string
bool notEmpty = str.isNotEmpty;
print('Is $str not empty: $notEmpty');
}
Is not empty: false
In this Dart tutorial, we learned about isNotEmpty property of String: the syntax and few working examples with output and detailed explanation for each example.