restingFillOpacity static method

double restingFillOpacity({
  1. required GlassSheetState state,
  2. required LiquidGlassSettings baseSettings,
  3. required bool enablePeek,
  4. LiquidGlassSettings? peekSettings,
  5. LiquidGlassSettings? halfSettings,
  6. LiquidGlassSettings? fullSettings,
})

Opacity the sheet's solid fill rests at in state.

Mirrors the fill branches of _calculateMetrics at rest so the droplet lands wearing the surface the sheet is about to show: a glass half detent hands off to glass, an opaque full detent hands off to opaque colour. Returning the wrong value here would show as a one-frame flash at the handoff, which is exactly what the unit tests pin down.

Implementation

static double restingFillOpacity({
  required GlassSheetState state,
  required LiquidGlassSettings baseSettings,
  required bool enablePeek,
  LiquidGlassSettings? peekSettings,
  LiquidGlassSettings? halfSettings,
  LiquidGlassSettings? fullSettings,
}) {
  final sPeek = peekSettings ?? baseSettings;
  final sHalf = halfSettings ?? baseSettings;
  final sFull = fullSettings ?? baseSettings;

  switch (state) {
    case GlassSheetState.full:
      // t == 1: the crossfade is complete whichever route got us here, so
      // only the explicit full-state settings can keep the surface glassy.
      if (fullSettings == null) return 1.0;
      return _fillFor(from: sHalf, to: sFull, t: 1.0);
    case GlassSheetState.half:
      // t == 0: the half→full crossfade hasn't started. Without explicit
      // full settings the sheet is opaque only when its own surface has no
      // blur to show through.
      if (fullSettings == null) {
        return (sHalf.blur == 0 || baseSettings.blur == 0) ? 1.0 : 0.0;
      }
      return _fillFor(from: sHalf, to: sFull, t: 0.0);
    case GlassSheetState.peek:
      if (!enablePeek) return sHalf.blur == 0 ? 1.0 : 0.0;
      return _fillFor(from: sPeek, to: sHalf, t: 0.0);
    case GlassSheetState.hidden:
      return 0.0;
  }
}