Answers for "how to generate randonm string in flutter"

3

create random string with numbers dart

import 'dart:math';

void main() {
  print(getRandomString(5));  // 5GKjb
  print(getRandomString(10)); // LZrJOTBNGA
  print(getRandomString(15)); // PqokAO1BQBHyJVK
}

import 'dart:math';

String generateRandomString(int len) {
  var r = Random();
  const _chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
  return List.generate(len, (index) => _chars[r.nextInt(_chars.length)]).join();
}
Posted by: Guest on February-28-2021

Code answers related to "how to generate randonm string in flutter"

Browse Popular Code Answers by Language