Map isEmpty

Map isEmpty property returns a boolean value of true if this Map is empty, or false if this Map is not empty.

Syntax

The syntax to check if the Map myMap is empty is

myMap.isEmpty

Examples

Check if Map is Empty

In the following Dart Program, we take a Map myMap with no key-value pairs, and programmatically check if this Map is empty, using Map.isEmpty property.

main.dart

</>
Copy
void main() {
    var myMap = {};
    if ( myMap.isEmpty ) {
        print('Map is empty.');
    } else {
        print('Map is not empty.');
    }
}

Output

Map is empty.

Conclusion

In this Dart Tutorial, we learned how to check if given Map is empty, using Map.isEmpty property.