asView<T extends TypedDataList> method
Zero-copy view as T.
T must be a concrete TypedDataList type: Uint8List, Int32List,
Float32List, etc. Throws if T isn't one of those.
Invalid after free/heap growth.
Implementation
@override
T asView<T extends TypedDataList>(int length) {
MemoryDebug.checkPointer(this, 'asView', T, length);
return switch (T) {
const (Uint8List) => _ptr.cast<Uint8>().asTypedList(length) as T,
const (Int8List) => _ptr.cast<Int8>().asTypedList(length) as T,
const (Uint16List) => _ptr.cast<Uint16>().asTypedList(length) as T,
const (Int16List) => _ptr.cast<Int16>().asTypedList(length) as T,
const (Uint32List) => _ptr.cast<Uint32>().asTypedList(length) as T,
const (Int32List) => _ptr.cast<Int32>().asTypedList(length) as T,
const (Uint64List) => _ptr.cast<Uint64>().asTypedList(length) as T,
const (Int64List) => _ptr.cast<Int64>().asTypedList(length) as T,
const (Float32List) => _ptr.cast<Float>().asTypedList(length) as T,
const (Float64List) => _ptr.cast<Double>().asTypedList(length) as T,
_ => throw UnsupportedError('NativeMemoryPointer.asView<$T> not implemented'),
};
}