randString static method
Mixins.randString(10); // generate random string value
Implementation
static String randString(int length,
{bool withSymbol = false, List<String> customChar = const []}) {
String chars =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if (customChar.isNotEmpty) {
chars = customChar.join();
}
if (withSymbol) {
chars += '!@#\$%^&*()_+-=[]{}|;:<>?,./';
}
if (length < 1) length = 1;
String rand = '';
for (int i = 0; i < length; i++) {
rand += chars[Random().nextInt(chars.length)];
}
return rand;
}