Skip to content
pubscout

rnd

0.2.0, released 5 years ago by gskinner.com

Extension methods and helper functions for Random, plus a globally accessible instance.

WASM-ready
$ flutter pub add rnd
Source repository

What it does

It provides extension methods for Dart's Random class to easily generate bounded numbers, booleans, colors, and list items. It also exposes a globally accessible Random instance for quick random value generation across the app.

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

Use it when

  • You need quick, concise generation of random numbers, colors, or list items without boilerplate.
  • You want a global Random instance that can be easily seeded throughout your app.

Skip it when

  • You require cryptographically secure random numbers.

Strengths

  • Convenient extension methods like getInt, getBool, and getItem.
  • Global instance simplifies random calls across the codebase.
  • Supports curve transformations for value distributions.

Weaknesses

  • Relies on a global mutable instance which may complicate unit testing in some architectures.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:rnd/rnd.dart';
rnd(10); // random double between 0-10
rnd.getBool(0.8); // 80% chance to get true

Alternatives

Packages that do the same job and could replace rnd.