FromTypedData method

P FromTypedData(
  1. TypedData data, {
  2. String? key,
})
inherited

Copies data into a slot by reinterpreting its bytes as elements of type X.

Unlike FromTypedList, accepts any TypedData regardless of its element type, converting via the underlying byte buffer. data must be a whole number of byteSize-sized elements.

Implementation

P FromTypedData(TypedData data, {String? key}) {
  final byteCount = data.lengthInBytes;
  assert(byteCount % byteSize == 0);
  final length = byteCount ~/ byteSize;
  final p = Sized(length, key: key);
  final src = fromBuffer(data.buffer, data.offsetInBytes, length);
  asView(pointerToSource(p), length).setAll(0, src);
  return p;
}