generateRandomString method
String
generateRandomString(
- int length, {
- bool includeUppercase = true,
- bool includeNumber = true,
})
Implementation
String generateRandomString(int length,
{final bool includeUppercase = true, final bool includeNumber = true}) {
if (length <= 0) {
length = generateRandomInt(minimum: 1);
}
final StringBuffer buffer = StringBuffer();
for (int index = 0; index < length; index++) {
if (_random.nextBool()) {
buffer
.write(_generateRandomAlphabet(includeUppercase: includeUppercase));
} else if (includeNumber) {
buffer.write(generateRandomInt());
} else {
buffer
.write(_generateRandomAlphabet(includeUppercase: includeUppercase));
}
}
return buffer.toString();
}