singleOrNull property
T?
get
singleOrNull
Checks that the set has only one element, and returns that element.
Return null
if the set is empty or has more than one element.
Implementation
T? get singleOrNull => length != 1 ? null : single;