hasKeyValue method

bool hasKeyValue(
  1. String key,
  2. T value
)

Checks given key/value is exists or not

key is the key of the map. value is the value of the map.

Returns true if the key/value pair exists in the map.

Example:

var map = {'name': 'John', 'age': 25};
map.hasKeyValue('name', 'John'); // true
map.hasKeyValue('age', 25); // true
map.hasKeyValue('gender', 'male'); // false

Implementation

bool hasKeyValue(String key, T value) => any(
      (T element) {
        if (element is! Map<T, T>) {
          return false;
        }
        return element.has(key, value);
      },
    );