aw method

double aw(
  1. BuildContext context
)

Linearly interpolates between item1 and item2 based on the current screen width relative to the design width range (designMinWidth to designMaxWidth).

Useful for "Fluid Typography", spacing, or any dimension that should grow proportionally. Subscribes only to width changes for maximum performance.

Implementation

double aw(BuildContext context) {
  final data = FlexiInheritedWidget.of(context, aspect: FlexiAspect.width);
  if (data == null) throw Exception('FlexiConfig not found in context.');
  double smallScreenValue = item1.toDouble();
  double largeScreenValue = item2.toDouble();
  double minWidth = data.deviceTypeConfig.designMinWidth;
  double maxWidth = data.deviceTypeConfig.designMaxWidth;
  if (data.screenWidth <= minWidth) return smallScreenValue;
  if (data.screenWidth >= maxWidth) return largeScreenValue;

  final divisor = maxWidth - minWidth;
  assert(divisor > 0, 'Design width range must be positive.');

  return smallScreenValue +
      (largeScreenValue - smallScreenValue) *
          (data.screenWidth - minWidth) /
          max(1.0, divisor);
}