containsAll方法

bool containsAll(
  1. Iterable<Object?> other
)
override

判断此集合是否包含other中的所有元素。

final characters = <String>{'A', 'B', 'C'};
final containsAB = characters.containsAll({'A', 'B'});
print(containsAB); // true
final containsAD = characters.containsAll({'A', 'D'});
print(containsAD); // false

实现

bool containsAll(Iterable<Object?> other) {
  for (var o in other) {
    if (!contains(o)) return false;
  }
  return true;
}