v1buffer method
Generates a time-based version 1 UUID into a provided buffer
By default it will generate a string based off current time, and will
place the result into the provided buffer
. The buffer
will also be returned..
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 V1Options
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.2.2
Example: In-place generation of two binary IDs
// Generate two ids in an array
var myBuffer = new List(32); // -> []
uuid.v1buffer(myBuffer);
// -> [115, 189, 5, 128, 201, 91, 17, 225, 146, 52, 109, 0, 9, 0, 52, 128, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
uuid.v1buffer(myBuffer, offset: 16);
// -> [115, 189, 5, 128, 201, 91, 17, 225, 146, 52, 109, 0, 9, 0, 52, 128, 115, 189, 5, 129, 201, 91, 17, 225, 146, 52, 109, 0, 9, 0, 52, 128]
// Optionally use uuid.unparse() to get stringify the ids
uuid.unparse(myBuffer); // -> '73bd0580-c95b-11e1-9234-6d0009003480'
uuid.unparse(myBuffer, offset: 16) // -> '73bd0581-c95b-11e1-9234-6d0009003480'
Implementation
List<int> v1buffer(
List<int> buffer, {
@Deprecated('use config instead. Removal in 5.0.0')
Map<String, dynamic>? options,
V1Options? config,
int offset = 0,
}) {
var result = options != null ? v1(options: options) : v1(config: config);
return UuidParsing.parse(result, buffer: buffer, offset: offset);
}