v4buffer method

List<int> v4buffer(
  1. List<int> buffer, {
  2. @Deprecated('use config instead. Removal in 5.0.0') Map<String, dynamic>? options,
  3. V4Options? config,
  4. int offset = 0,
})

Generates a RNG version 4 UUID into a provided buffer

By default it will generate a string based off cryptoRNG, and will place the result into the provided buffer. The buffer will also be returned. If you wish to have crypto-strong RNG, pass in UuidUtil.cryptoRNG.

Optionally an offset can be provided with a start position in the buffer.

The first optional argument is an options map that takes various configuration options detailed in the readme. This is going to be eventually deprecated.

The second optional argument is a V4Options object that takes the same options as the options map. This is the preferred way to pass options.

http://tools.ietf.org/html/rfc4122.html#section-4.4

Example: Generate two IDs in a single buffer

var myBuffer = new List(32);
uuid.v4buffer(myBuffer);
uuid.v4buffer(myBuffer, offset: 16);

Implementation

List<int> v4buffer(
  List<int> buffer, {
  @Deprecated('use config instead. Removal in 5.0.0')
  Map<String, dynamic>? options,
  V4Options? config,
  int offset = 0,
}) {
  var result = options != null ? v4(options: options) : v4(config: config);
  return UuidParsing.parse(result, buffer: buffer, offset: offset);
}