Skip to content
/ chance Public

An easy-to-use library for Dart to generate random numbers, strings etc. - inspired by chance.js

License

Notifications You must be signed in to change notification settings

r-unruh/chance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chance

A minimalist set of functions to generate random numbers, strings etc.

Provides common convenience methods for getting some randomness.

This was initially inspired by the great JavaScript library chance.js but then took a more frugal approach. Instead of stuffing it with all kinds of heavy functions it provides you with just the basics that allow you to build upon.

Usage

import 'package:chance/chance.dart';

int foo = randomInt(3, 12); // 6

double bar = randomDouble(10, 20); // 10.9634128828224

bool lorem = randomBool(.2); // false

String ipsum = randomString(8); // 'Hxmde8XA'

String dolor = randomItem(['cat', 'dog', 'tiger']); // 'cat'

dynamic sit = randomItemOrNull([]); // null

That's it, that's the whole API. Enjoy!

About

An easy-to-use library for Dart to generate random numbers, strings etc. - inspired by chance.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages