List myList = [];
if(myList.isEmpty) {
print('The list is empty');
}
Output
The list is empty
In the above code example:
We can also use List.length in Dart to check if a list is empty. This will return 0 if the list is empty. We can understand it using the below code example.
List myList = [];
if(myList.length == 0) {
print('The list is empty');
}
Output
The list is empty
0 Comments