Card class abstract
A piece of playing cards.
final card = Card(Rank.ace, Suit.spade);
assert(card.rank == Rank.ace);
assert(card.suit == Suit.spade);
assert(card.toString() == "As");
Since Card implements Comparable, you can sort a list of Cards in order.
const cards = [
Card(Rank.ace, Suit.spade),
Card(Rank.king, Suit.club),
Card(Rank.queen, Suit.heart),
Card(Rank.jack, Suit.diamond),
];
cards.sort();
print(cards); // [
// Card(Rank.ace, Suit.spade),
// Card(Rank.queen, Suit.heart),
// Card(Rank.jack, Suit.diamond),
// Card(Rank.king, Suit.club)
// ]
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
Returns the hash integer value of this card.
no setter
- rank → Rank
-
The Rank of this card.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- suit → Suit
-
The Suit of this card.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation. Ace of spade is
"As"
, 10 of heart is"Th"
and deuce of diamond is"2d"
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited