dart:typed_data
库中ByteData.view
的用法介绍如下。
用法:
ByteData.view(
ByteBuffer buffer,
[int offsetInBytes = 0,
int? length]
)
在 buffer
中创建指定区域的 ByteData view
。
ByteData 中的更改将在字节缓冲区中可见,反之亦然。如果未指定区域的offsetInBytes
索引,则默认为零(字节缓冲区中的第一个字节)。如果未提供长度,则视图将扩展到字节缓冲区的末尾。
offsetInBytes
和 length
必须为非负数,并且 offsetInBytes
+ length
必须小于或等于 buffer
的长度。
请注意,当从 TypedData 列表或字节数据创建视图时,该列表或字节数据本身可能是较大缓冲区上的视图,其中 TypedData.offsetInBytes 大于零。仅执行 ByteData.view(other.buffer, 0, count)
可能不会指向您想要的字节。相反,您可能需要这样做:
ByteData.view(other.buffer, other.offsetInBytes, count)
或者,使用包含此计算的ByteData.sublistView:
ByteData.sublistView(other, 0, count);
(第三个参数是结束索引而不是长度,所以如果从大于零的位置开始,则不需要相应减少计数)。
相关用法
- Dart ByteData用法及代码示例
- Dart Base64Encoder用法及代码示例
- Dart BigInt.toRadixString用法及代码示例
- Dart BigInt.operator_divide用法及代码示例
- Dart BigInt用法及代码示例
- Dart BigInt.from用法及代码示例
- Dart BigInt.isValidInt用法及代码示例
- Dart BigInt.toDouble用法及代码示例
- Dart BigInt.parse用法及代码示例
- Dart BigInt.bitLength用法及代码示例
- Dart BigInt.gcd用法及代码示例
- Dart BigInt.operator_truncate_divide用法及代码示例
- Dart BigInt.tryParse用法及代码示例
- Dart BigInt.compareTo用法及代码示例
- Dart BigInt.remainder用法及代码示例
- Dart BigInt.toInt用法及代码示例
- Dart BigInt.operator_modulo用法及代码示例
- Dart BigInt.toUnsigned用法及代码示例
- Dart BigInt.toString用法及代码示例
- Dart Base64Decoder用法及代码示例
- Dart BigInt.pow用法及代码示例
- Dart BigInt.toSigned用法及代码示例
- Dart MapMixin.containsKey用法及代码示例
- Dart Iterator用法及代码示例
- Dart AttributeClassSet.intersection用法及代码示例
注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 ByteData.view constructor。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。