To check if a list is empty in Dart, you can use the isEmpty property of the list.
In this example,
myList
.isEmpty
property of myList
to check if it is empty.isEmpty
property returns true
if the list is empty, otherwise false
.void main() {
List<int> myList = [];
bool isEmpty = myList.isEmpty;
print("Is list empty: \${isEmpty ? 'true' : 'false'}");
}
Is list empty: true
In this tutorial, we learned How to check if a List is Empty in Dart language with well detailed examples.