lookup abstract method

  1. @override
T? lookup(
  1. covariant T element
)
override

If an object equal to element is in the set, return it.

Checks whether element is in the set, like contains, and if so, returns the object in the set, otherwise returns null.

If the equality relation used by the set is not identity, then the returned object may not be identical to element. Some set implementations may not be able to implement this method. If the contains method is computed, rather than being based on an actual object instance, then there may not be a specific object instance representing the set element.

final characters = <String>{'A', 'B', 'C'};
final containsB = characters.lookup('B');
print(containsB); // B
final containsD = characters.lookup('D');
print(containsD); // null

Implementation

@override
T? lookup(covariant T element);