Skip to content
pubscout

xrandom

0.7.2, released 5 years ago by revercode.com

Consistent, high-performance, and reproducible random number generators in Dart.

WASM-ready
$ flutter pub add xrandom
Source repository

What it does

Provides classes implementing various pseudorandom number generators with the same API as dart:math's Random. It ensures bit-accurate numbers across platforms and supports reproducibility and high-quality randomness for simulations.

AI-written summary of version 0.7.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need reproducible random sequences for testing or simulations
  • You need consistent random results across different native platforms
  • You want faster alternatives to dart:math's Random

Skip it when

  • Your target platform is JavaScript and you need to use 64-bit generators that are unsupported there
  • You are looking for cryptographically secure random numbers

Strengths

  • Bit-accurate consistency across different platforms
  • Multiple well-known RNG algorithms available (Xorshift, Xoshiro, Splitmix, Mulberry)
  • Faster execution times compared to standard dart:math Random in benchmarks

Weaknesses

  • Some 64-bit generators are unsupported on JavaScript and will throw an UnsupportedError
  • Not cryptographically secure

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:xrandom/xrandom.dart';

final random = Xrandom();
var a = random.nextBool();
var b = random.nextDouble();
var c = random.nextInt(100);

Alternatives

Packages that do the same job and could replace xrandom.

  • nanoid2

    A tiny, secure, URL-friendly, unique string ID generator with a pure Dart API.

  • uid

    Generates timestamp‑based unique IDs and random barcodes with configurable length and charset.

  • flutter_lorem

    Generates random placeholder sentences and paragraphs for UI design.

  • nonce

    Generate random alphanumeric strings and unique nonces in Dart.