responsiveValue<T> function

T responsiveValue<T>(
  1. BuildContext context, {
  2. required T mobile,
  3. T? tablet,
  4. T? desktop,
  5. T? widescreen,
})

Returns a value based on the current device type (screen width).

Uses ResponsiveDimensions extension which reads breakpoints from AdaptiFlowData configuration.

final columns = responsiveValue(
  context,
  mobile: 1,
  tablet: 2,
  desktop: 3,
  widescreen: 4,
);

Implementation

T responsiveValue<T>(
  BuildContext context, {
  required T mobile,
  T? tablet,
  T? desktop,
  T? widescreen,
}) {
  if (context.isWidescreen) return widescreen ?? desktop ?? tablet ?? mobile;
  if (context.isDesktop) return desktop ?? tablet ?? mobile;
  if (context.isTablet) return tablet ?? mobile;
  return mobile;
}