flatten static method

List<Dice> flatten(
  1. List<Dice> dice
)

Flattens a list of dice into a list of dice with the amount set to 1, each dice roll separated into its own dice.

Implementation

static List<Dice> flatten(List<Dice> dice) => dice.fold(
    [], (all, cur) => [...all, ...List.filled(cur.amount, cur / cur.amount)]);