get random 4 digit in flutter code example Example: random number dart with length 7 var rng = new Random(); var code = rng.nextInt(900000) + 100000;