我想在 dart 中使用型別串列,它可以是以下型別之一
/// The array is typed array it can be :
/// - Float64List
/// - Float32List
/// - Int32List
/// - Uint32List
/// - Int16List
/// - Uint16List
/// - Uint8ClampedList
/// - Uint8List
/// - Int8List
///
/// and can be the object positions, colors, normals or uvs or indices
dynamic array;
我想要這樣的東西
TypedArray array;
現在我使用動態,但我想使用一個抽象類,它具有型別串列的所有屬性。
我怎么能做到這一點謝謝大家。
我正在嘗試做的一個例子
class BufferAttribute {
/// The array is typed array it can be :
/// - Float64List
/// - Float32List
/// - Int32List
/// - Uint32List
/// - Int16List
/// - Uint16List
/// - Uint8ClampedList
/// - Uint8List
/// - Int8List
///
/// and can be the object positions, colors, normals or uvs or indices
TypedData array;
/// 1,2 or 3 components per iteration
int itemSize;
bool normalized;
/// the number of elements in the array.
/// how is computed: array.length / numbe of components.
int count = 0;
/// gl.STATIC_DRAW
int usage = 35044;
BufferAttribute(this.array, this.itemSize, [this.normalized = false]) {
count = array.length ~/ itemSize; <---- I get an Error
usage = 35044; // gl.STATIC_DRAW
}
}
The error says:
The getter 'length' isn't defined for the type 'TypedData'.
Try importing the library that defines 'length', correcting the name to the name of an existing getter, or defining a getter or field named 'length'.dartundefined_getter
uj5u.com熱心網友回復:
那應該是TypedData:
TypedData array = UInt8List(...);
知道了,但是,基本型TypedData不暴露許多成員,只有屬性buffer,elementSizeInBytes,lengthInBytes,和offsetInBytes。我不知道這會有多大用處,根據您的目的,抽象的數量可能會過大。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/344857.html
標籤:镖
下一篇:從子小部件更改父小部件中的屬性
