SheetGeometry class
Pure geometry calculations for sheet snap positions — no BuildContext, no side effects.
Encapsulates which detents are active, their physical positions, and the logic for resolving snap targets and rubber-band resistance. Fully testable without a widget tree.
Constructors
- SheetGeometry({required GlassSheetMode mode, required double halfSize, double? fullSize, required double peekSize, bool enablePeek = true, bool enableHalf = true, bool enableFull = true, bool dismissible = true, bool fitsContent = false, double? contentHeight})
-
Creates a sheet geometry configuration.
const
Properties
- contentHeight → double?
-
The height in logical pixels that the sheet's one stop fits
when fitsContent is true, or null while it is not yet known.
final
- dismissible → bool
-
Whether the sheet can be dragged below its lowest detent to dismiss.
final
- enableFull → bool
-
Whether the full-screen detent is active.
final
- enableHalf → bool
-
Whether the half-height detent is active.
final
- enablePeek → bool
-
Whether the peek floor detent is active.
final
- fitsContent → bool
-
Whether the sheet's one stop fits contentHeight. See
GlassSheetDetent.fitted.
final
- fullSize → double?
-
Optional explicit height for the GlassSheetState.full detent.
When null, defaults to
screenHeight - 90.0.final - halfSize → double
-
Height of the GlassSheetState.half detent in logical pixels (> 1.0)
or as a screen-height fraction (≤ 1.0).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxState → GlassSheetState
-
The highest detent in the active configuration.
no setter
- minState → GlassSheetState
-
The lowest detent in the active configuration.
no setter
- mode → GlassSheetMode
-
The dismissal mode (dismissible vs persistent floor).
final
-
orderedStates
→ List<
GlassSheetState> -
The rest states this sheet can occupy, ordered low → high. This is the
single source of truth for the state machine — snapping, min/max bounds,
and resistance all derive from it, so a sheet can omit any of peek / half
/ full and the machine simply routes around the missing detent.
no setter
- peekSize → double
-
Height of the GlassSheetState.peek floor detent.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
applyResistance(
double rawPosition, double screenHeight, {required double resistance, double? minDetentResistance}) → double - Applies rubber-band resistance when dragging beyond bounds.
-
fittedLimitPosition(
double screenHeight) → double - Upper bound for a content-fitted sheet: the position of the full stop, from fullSize, although that stop is not active.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
positionForState(
GlassSheetState state, double screenHeight) → double -
Like positionFor but applies cascade constraints so snap positions are
always ordered:
hidden ≤ peek ≤ half ≤ full. -
resolveTarget(
SheetSnapshot current, {required double snapThreshold, required double velocityThreshold}) → GlassSheetState - Computes target state based on current position and velocity.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
positionFor(
GlassSheetState state, double screenHeight, {GlassSheetMode? mode, double? halfSize, double? fullSize, double? peekSize}) → double -
Returns the normalized position (0.0–1.0) for
stategivenscreenHeight. -
resolveFitsContent(
{required Set< GlassSheetDetent> detents, required GlassSheetMode mode}) → bool - Resolve whether the sheet fits its content, from the public API's detents and mode.
-
resolveFull(
{required Set< GlassSheetDetent> detents}) → bool - Resolve whether the full stop is active, from the public API's detents.
-
resolveHalf(
{required Set< GlassSheetDetent> detents}) → bool - Resolve whether the half stop is active, from the public API's detents.
-
resolveInitialState(
GlassSheetState requested, {required Set< GlassSheetDetent> detents, required GlassSheetMode mode}) → GlassSheetState -
Resolve the state a sheet opens at, from the
requestedinitial state and the public API's detents and mode. -
resolvePeek(
{required Set< GlassSheetDetent> detents, required GlassSheetMode mode}) → bool - Resolve whether the peek floor is active, from the public API's detents and mode.