find<T extends Card> method
Looks up a card in this collection by its orderInSet
.
If the card is not found, throws a StateError.
If the card is found, but is not of type T
, throws a StateError. For
example, if you call tryFind<UnitCard>(1)
on a collection that contains
a BaseCard at order 1
, an error will be thrown.
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
T find<T extends Card>(int orderInSet, [String? debugAssertName]) {
final result = tryFind<T>(orderInSet, debugAssertName);
if (result != null) {
return result;
}
throw StateError('Card not found: $orderInSet');
}