How to generate random numbers in dart.
1. Import math from dart:math.
2. Create an object of Random class name random.
3. Call nextInt() method and store it in randomNumber variable which type is int.
4. It will generate 0 to 9 random number.
Example :
import 'dart:math';
Random random = new Random();
int randomNumber = random.nextInt(10); // from 0 upto 9 included
0 Comments
If you have any question please ask?