getRawDataPointer function Null safety

Pointer<Uint8> getRawDataPointer(
  1. List planes
)

Implementation

Pointer<Uint8> getRawDataPointer(List<Plane> planes) {
  int totalBytes = 0;
  int offset = 0;

  for (int i = 0; i < planes.length; ++i) {
    totalBytes += planes[i].bytes.length;
  }

  Pointer<Uint8> result = malloc.allocate(totalBytes);
  Uint8List list = result.asTypedList(totalBytes);

  for (Plane plane in planes) {
    list.setAll(offset, plane.bytes);

    offset += plane.bytes.length;
  }

  return result;
}