responsiveValue<T> function
T
responsiveValue<T>(
- BuildContext context, {
- required T mobile,
- T? tablet,
- T? desktop,
- 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;
}