SSpreadsheetZoomController class

Shared zoom state for SSpreadsheet.

Holds the zoom factor together with the policy around it — the range it is clamped to and the increments a button press or a wheel notch applies — so a toolbar control, the keyboard shortcuts and the widget's own wheel handling can never disagree about what "zoom in" means.

The increments are absolute additions to the factor, not multipliers: within a 50%–200% range that makes every press the same size, so pressing "zoom in" from 50% and from 200% moves the sheet by the same amount.

Pass one instance to SSpreadsheet.zoomController to drive zoom from outside — a toolbar control, a settings row, an app-level bridge. Ownership follows SSpreadsheetHorizontalSyncController: a caller-supplied controller is only ever listened to, with the listener attached when the spreadsheet mounts and detached when it unmounts, and is never disposed by the spreadsheet; a controller the spreadsheet had to create for itself is disposed with it. SSpreadsheetSelectionController is borrowed the same way.

The zoom is deliberately not persisted: it lives and dies with this controller, so a fresh app start is back at defaultZoom (100%).

Inheritance

Constructors

SSpreadsheetZoomController({double zoom = defaultZoom, double minZoom = defaultMinZoom, double maxZoom = defaultMaxZoom, double step = defaultStep, double wheelStep = defaultWheelStep})

Properties

canZoomIn → bool
Whether zoomIn would change anything — false at maxZoom.
no setter
canZoomOut → bool
Whether zoomOut would change anything — false at minZoom.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
maxZoom → double
Largest factor setZoom clamps to — 200%.
final
minZoom → double
Smallest factor setZoom clamps to — 50%.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
step → double
Increment applied by zoomIn / zoomOut: one button press or one keystroke, i.e. 10% of 100%.
final
value ↔ double
The current value stored in this notifier.
getter/setter pairinherited
wheelStep → double
Increment applied by one wheel notch (or one trackpad pinch tick).
final
zoom → double
The current factor, where 1.0 is 100%.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
reset({Offset? anchor}) → bool
Back to defaultZoom (100%), clamped like any other setZoom.
setZoom(double next, {Offset? anchor}) → bool
Sets the factor to next, clamped to minZoom..maxZoom.
takeAnchor() → Offset?
The anchor of the most recent zoom that changed the factor, or null.
toString() → String
A string representation of this object.
inherited
zoomByWheelNotches(double notches, {Offset? anchor}) → bool
notches wheel notches worth of wheelStep, positive to zoom in.
zoomIn({Offset? anchor}) → bool
One step larger, clamped. See setZoom for the return value.
zoomOut({Offset? anchor}) → bool
One step smaller, clamped. See setZoom for the return value.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

defaultMaxZoom → const double
Largest factor a default-configured controller clamps to — 200%.
defaultMinZoom → const double
The range and increments a default-configured controller uses.
defaultStep → const double
Increment a default-configured controller applies per button press.
defaultWheelStep → const double
Increment a default-configured controller applies per wheel notch.
defaultZoom → const double
The factor the sheet is shown at with no zoom applied, i.e. 100%.