Random(seed) from dart:math is a pseudo-random number generator. Given the same seed, it produces the same sequence of nextInt, nextDouble, and nextBool results across runs, which keeps tests, demos, and offline replay deterministic. The page draws two nextInt(100) values, a nextDouble, and a nextBool from a Random(42), formats the double for output, then builds a fresh Random(42) and confirms its first value matches the original.

Program

Play the program to draw a fixed sequence from Random(42), format the double, then verify that a brand-new Random(42) reproduces the first value.

random_seeded.dart
import 'dart:math';

void main() {
  var rng = Random(42);
  var n1 = rng.nextInt(100);
  var n2 = rng.nextInt(100);
  var d = rng.nextDouble();
  var shown = d.toStringAsFixed(4);
  var flip = rng.nextBool();
  var again = Random(42).nextInt(100);
  print('$n1 $n2 $shown $flip again=$again');
}
seeded Random `Random(seed)` is a pseudo-random generator. The full sequence of `nextInt`, `nextDouble`, and `nextBool` results is determined by the seed.
reproducibility A fresh `Random(42)` returns the same first `nextInt(100)` (here `87`) as the original instance, so tests and demos stay deterministic.
nextInt nextDouble nextBool `nextInt(n)` returns `0..n-1`; `nextDouble()` returns a value in `[0.0, 1.0)`; `nextBool()` returns `true` or `false`. Each random call advances the generator's internal state.
formatting `toStringAsFixed(4)` formats the double draw as a `String` for short output; the original `double` value remains unchanged.