nextBytes method

Uint8List nextBytes(
  1. int length
)

Generates a list of length random bytes.

Example:

var bytes = Random().nextBytes(10); // Generates 10 random bytes.

Implementation

Uint8List nextBytes(int length) {
  final Uint8List bytes = Uint8List(length);
  for (int i = 0; i < length; i++) {
    bytes[i] = _random.nextInt(256); // Generate a random byte (0-255)
  }
  return bytes;
}