Int64List.view constructor
- ByteBuffer buffer, [
- int offsetInBytes = 0,
- int? length
Creates an Int64List view of the specified region in buffer
.
Changes in the Int64List will be visible in the byte buffer
and vice versa.
If the offsetInBytes
index of the region is not specified,
it defaults to zero (the first byte in the byte buffer).
If the length is not provided,
the view extends to the end of the byte buffer.
The offsetInBytes
and length
must be non-negative, and
offsetInBytes
+ (length
* bytesPerElement) must be less than or
equal to the length of buffer
.
The offsetInBytes
must be a multiple of bytesPerElement.
Note that when creating a view from a TypedData list or byte data,
that list or byte data may itself be a view on a larger buffer
with a TypedData.offsetInBytes greater than zero.
Merely doing Int64List.view(other.buffer, 0, count)
may not
point to the bytes you intended. Instead you may need to do:
Int64List.view(other.buffer, other.offsetInBytes, count)
Alternatively, use Int64List.sublistView which includes this computation:
Int64List.sublistView(other, 0, count);
(The third argument is an end index rather than a length, so if you start from a position greater than zero, you need not reduce the count correspondingly).
Implementation
factory Int64List.view(
ByteBuffer buffer, [
int offsetInBytes = 0,
int? length,
]) {
return buffer.asInt64List(offsetInBytes, length);
}