The map.isEmpty
function in Dart is used to check if a map is empty or not.
map.isEmpty
returns true
if the map is empty, i.e., no key-value pairs exist. Otherwise, it returns false
.
The illustration below shows a visual representation of the map.isEmpty
function:
bool map_name.isEmpty
map_name
is the name of the map.
The map.isEmpty
function does not require any parameters.
If the map is empty, the map.isEmpty
function returns true
.
Otherwise, it returns false
.
The following code shows how to use map.isEmpty
function in Dart:
import 'dart:convert';void main() {var map_1 = new Map();map_1 [1] = 'Tom';map_1 [2] = 'Alsvin';map_1 [3] = 'Eddie';//map containg key value pairsprint("map_1 is empty: ${map_1.isEmpty}");//map emptyvar map_2 = new Map();print("map_2 is empty: ${map_2.isEmpty}");}