responsiveValue<T> method

T responsiveValue<T>({
  1. required T desktop,
  2. T? tablet,
  3. T? mobile,
})

Evaluates and returns the corresponding value for the current breakpoint.

desktop is the main/base value expected (large screens). tablet and mobile are optional and will fallback to desktop if they are not specified.

Example:

final double paddingSize = context.responsiveValue(
  mobile: 16.0,
  tablet: 24.0,
  desktop: 32.0,
);

Implementation

T responsiveValue<T>({required T desktop, T? tablet, T? mobile}) {
  if (isMobile && mobile != null) return mobile;
  if (isTablet && tablet != null) return tablet;
  return desktop;
}