tryFindToken method
Looks up a token in this collection by its orderInSet
.
If the card is not found, returns null
.
If debugAssertName
is provided, in debug mode (assertions enabled) the
card's name will be checked against it, exactly as written. This is useful
for debugging, but should not be relied upon.
Implementation
TokenCard? tryFindToken(int orderInSet, [String? debugAssertName]) {
final card = _lookupTokens[orderInSet - 1];
if (card == null) {
return null;
}
assert(
debugAssertName == null || card.name == debugAssertName,
'Expected $debugAssertName, got ${card.name}',
);
return card;
}