setFitRect method
Update the rect into which the image should fit. Snaps the camera on the first call (rect previously zero / source not yet decoded), animates otherwise. Re-entrant: a same-rect call short-circuits.
Implementation
void setFitRect(Rect next) {
if (fitRect.value == next) return;
final wasEmpty = fitRect.value.isEmpty;
fitRect.value = next;
final src = sourceSize;
if (src == null || next.isEmpty) return;
final target = _fitOf(next, _cameraContentRect);
if (wasEmpty || camera.value == vmath.Matrix4.zero()) {
cameraAnimator.cancel();
_animatedFit = target;
camera.value = target.toMatrix();
} else {
cameraAnimator.animate(target: target);
}
}