getBool method

bool getBool(
  1. String key
)

Reads a key value of bool type from Map.

If the key is not present in the map or the value of the key is not of type bool, the method will return the default value of false.

Example:

Map<String, dynamic> map = {'isAdmin': true, 'isActive': false};
print(map.getBool('isAdmin'));  // Output: true
print(map.getBool('isActive'));  // Output: false
print(map.getBool('isDeleted'));  // Output: false

Implementation

bool getBool(String key) => containsKey(key) && this[key] is bool;