The `isNotEmpty` property of the `Iterable` class returns true if there is at least one element in the collection, otherwise false.
The syntax of Runes.isNotEmpty property is:
bool isNotEmpty
This isNotEmpty property of Runes returns true if there is at least one element in this collection.
Runes.isNotEmpty returns value of type bool
.
In this example,
numbers
.isNotEmpty
property to check if the list has elements.void main() {
List<int> numbers = [1, 2, 3];
bool hasElements = numbers.isNotEmpty;
print('Has Elements: $hasElements'); // Prints: Has Elements: true
}
Has Elements: true
In this example,
names
.isNotEmpty
property to check if the list has elements.void main() {
List<String> names = [];
bool hasNames = names.isNotEmpty;
print('Has Names: $hasNames'); // Prints: Has Names: false
}
Has Names: false
In this Dart tutorial, we learned about isNotEmpty property of Runes: the syntax and few working examples with output and detailed explanation for each example.