responsiveValue<T> method

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

Returns a specific value according to the screen size if the device width is higher than or equal to 1200 return desktop value. if the device width is higher than or equal to 600 and less than 1200 return tablet value. if the device width is less than 300 return watch value. in other cases return mobile value.

Implementation

T responsiveValue<T>({
  T? mobile,
  T? tablet,
  T? desktop,
  T? watch,
}) {
  var deviceWidth = mediaQuerySize.shortestSide;
  if (UniversalPlatform.isDesktop) {
    deviceWidth = mediaQuerySize.width;
  }
  if (deviceWidth >= 1200 && desktop != null) {
    return desktop;
  } else if (deviceWidth >= 600 && tablet != null) {
    return tablet;
  } else if (deviceWidth < 300 && watch != null) {
    return watch;
  } else {
    return mobile!;
  }
}