setZoom method
Sets the factor to next, clamped to minZoom..maxZoom.
Returns whether the factor actually changed. A request that clamps back onto the current value is a no-op and notifies no listeners, so callers can drive this straight from a scroll wheel or a stream of button taps without guarding against the ends of the range.
anchor is the point — in the viewport's coordinates, i.e. the box the
sheet is painted into — that should stay put while the factor changes. It
is held for whoever applies the change, which is the only layer that can
see the scroll positions, and read back through takeAnchor. Passing
null means "keep the origin still", which is what a toolbar button
wants: the offsets the sheet tracks are content-space and do not change,
so the top-left row and column simply stay where they are.
Implementation
bool setZoom(double next, {Offset? anchor}) {
final clamped = next.clamp(minZoom, maxZoom).toDouble();
if (clamped == value) return false;
_pendingAnchor = anchor;
value = clamped;
return true;
}