setup<T> method

  1. @mustCallSuper
void setup<T>(
  1. MultiStateSheetExtent<T> extent
)

Configures the snapping behavior using the provided extent.

  • extent: The current state and configuration of the sheet.

Subclasses should not override setup directly. Instead, they should override performSetup method.

Clears cached values to ensure consistent calculations.

Implementation

@mustCallSuper
void setup<T>(MultiStateSheetExtent<T> extent) {
  cachedClosestOffsets.clear();
  cachedState.clear();
  cachedStateFromOffset.clear();

  headerShiftHeight = clipByHeader &&
          (extent.currentState == 0 && extent.stateInterpolation == 0.0)
      ? extent.componentSizes.header
      : 0.0;

  // Set the available space for the sheet.
  avaliableSpace = extent.availablePixels;
  final clippedMaxOffset = avaliableSpace - headerShiftHeight;

  // Initialize minimum and maximum offsets.
  minOffset = 0.0;
  maxOffset = clippedMaxOffset;

  // Combine snapping offsets from all models.
  snappingOffsets = performSetup(extent);

  // Update minimum and maximum offsets based on the calculated snapping offsets.
  minOffset = snappingPixelOffsets.firstOrNull ?? 0.0;

  maxOffset = math.min(
      clippedMaxOffset, snappingPixelOffsets.lastOrNull ?? clippedMaxOffset);
}