CardSet constructor

CardSet(
  1. String name, {
  2. required int totalCards,
  3. String? abbreviation,
  4. int totalTokens = 0,
})

Creates a card set with the given name and abbreviation.

If abbreviation is not provided, it is derived from name, by using the first letter of each word in name, in all caps. For example the abbreviation of "Spark of Rebellion" is "SOR".

Errors

This class is not intended to be used with user-provided input, and as such does not provide any error handling. If any of the fields are invalid, an error will be thrown.

Implementation

factory CardSet(
  String name, {
  required int totalCards,
  String? abbreviation,
  int totalTokens = 0,
}) {
  checkNotEmpty(value: name, name: 'name');
  abbreviation ??= _abbreviate(name);
  checkNotEmpty(value: abbreviation, name: 'abbreviation');

  checkPositive(totalCards, 'totalCards');
  RangeError.checkNotNegative(totalTokens, 'totalTokens');

  return CardSet._(
    abbreviation: abbreviation,
    fullName: name,
    totalCards: totalCards,
    totalTokens: totalTokens,
  );
}