VecRect.generate constructor

VecRect.generate(
  1. int length,
  2. Rect generator(
    1. int i
    ), {
  3. bool dispose = true,
})

Implementation

factory VecRect.generate(int length, Rect Function(int i) generator, {bool dispose = true}) {
  final pp = calloc<cvg.VecRect>()..ref.length = length;
  pp.ref.ptr = calloc<cvg.Rect>(length);
  for (var i = 0; i < length; i++) {
    final v = generator(i);
    pp.ref.ptr[i] = v.ref;
    if (dispose) v.dispose();
  }
  return VecRect.fromPointer(pp);
}