generateRandomString static method
Generates a random string from the provided characters.
length: The length of the string.
characters: The character set to use.
random: The Random instance for generating indices.
Returns a random string of specified length.
Implementation
static String generateRandomString({
required int length,
required String characters,
required Random random,
}) {
final codeUnits = List.generate(
length,
(_) => characters.codeUnitAt(random.nextInt(characters.length)),
);
return String.fromCharCodes(codeUnits);
}