我有一个String类型的变量,它是id。我想在其中生成一个从0到100的随机字符串编号,而不重复,我该如何执行此
final String keyRan = '0';
这个代码片段可能会有所帮助:
// generate a list of 0 to 100 (inclusive) as Strings
final numbers = List.generate(101, (index) => index.toString());
// shuffle those
numbers.shuffle();
// print each of them, just as an example here
numbers.forEach((number) => print(number));
// or take the last one each time
final number = numbers.removeLast();