randomStr static method
指定字符中生成指定长度的随机字符串 prefix前缀
Implementation
static String randomStr({int length = 32, String? prefix}) {
var len = length - (prefix?.length ?? 0);
final randomStr = List.generate(len,
(index) => _availableChars[_random.nextInt(_availableChars.length)])
.join();
if (prefix.isNotNull()) {
return "$prefix$randomStr";
} else {
return randomStr;
}
}