Random
Random is a generator of bool, int or double values.
var intValue = Random().nextInt(10); // Value is >= 0 and < 10.
var doubleValue = Random().nextDouble(); // Value is >= 0.0 and < 1.0.
var boolValue = Random().nextBool(); // true or false, with equal chance
Reference:
https://api.flutter.dev/flutter/dart-math/dart-math-library.html
Random rnd;
int min = 5;
int max = 10;
rnd = new Random();
r = min + rnd.nextInt(max - min);
print("$r is in the range of $min and $max");
//1 ile 5 arasında bir sayı döndür
import 'dart:math';
int max = 5;
int randomNumber = Random().nextInt(max) + 1;
int nextInt(int min, int max) => min + _random.nextInt((max + 1) - min);
import 'dart:math';
Random rnd = new Random();
// Define min and max value
int min = 1, max = 10;
//Getting range
int num = min + rnd.nextInt(max - min);
print("$num is in the range of $min and $max");
No comments:
Post a Comment