partial function Null safety
A matcher for maps that only checks the values of the provided keys.
This matcher only matches the keys from map
. Other keys in
the actual map are ignored, and any value will be accepted.
Example:
var map = {
"id": 1,
"name": "foo"
};
expect(map, partial({
"id": isInteger
})); // succeeds
You may enforce that the actual value does not have a key by storing isNotPresent for that key.
Example:
var map = {
"id": 1,
"name": "foo"
};
expect(map, partial({
"id": isInteger,
"name": isNotPresent
})); // fails because 'name' is present
Implementation
Matcher partial(Map<String, dynamic> map) => PartialMapMatcher(map);