validatedNativeResultCount function
Validates the element count reported by a native array fill against the
capacity of the buffer that was passed in.
Implementation
int validatedNativeResultCount(int count, int capacity) {
if (count < 0 || count > capacity) {
throw StateError(
'Native array fill returned count=$count outside 0..$capacity',
);
}
return count;
}