zeroed method

Float32List zeroed(
  1. int sizeInBytes
)

A list of sizeInBytes / 4 floats, all zero: the same list every time this size is asked for, cleared first, so a member the caller does not write reads zero as it did in a fresh list.

sizeInBytes is a multiple of four, as a uniform block's size is.

Implementation

Float32List zeroed(int sizeInBytes) {
  assert(
    sizeInBytes >= 0 && sizeInBytes % 4 == 0,
    'a uniform block is a whole number of floats, not $sizeInBytes bytes',
  );
  final list = _bySize[sizeInBytes] ??= Float32List(sizeInBytes ~/ 4);
  return list..fillRange(0, list.length, 0);
}