resolveValue<T> method

T resolveValue<T>({
  1. required T defValue,
  2. T? defLandscape,
  3. T? phone,
  4. T? phoneLandscape,
  5. T? tablet,
  6. T? tabletLandscape,
  7. T? desktop,
  8. T? largeDesktop,
  9. T? watch,
})

Implementation

T resolveValue<T>({
  required T defValue,
  T? defLandscape,
  T? phone,
  T? phoneLandscape,
  T? tablet,
  T? tabletLandscape,
  T? desktop,
  T? largeDesktop,
  T? watch,
}) {
  T? orientationValue(T? portraitValue, T? landscapeValue) {
    switch (orientation) {
      case Orientation.landscape:
        return landscapeValue ?? portraitValue;
      case Orientation.portrait:
        return portraitValue;
    }
  }

  T? value;
  switch (screenType) {
    case ResponsiveScreenType.desktop:
      value = orientationValue(desktop, largeDesktop) ??
          orientationValue(tablet, tabletLandscape);
      break;
    case ResponsiveScreenType.tablet:
      value = orientationValue(tablet, tabletLandscape);
      break;
    case ResponsiveScreenType.phone:
      value = orientationValue(phone, phoneLandscape);
      break;
    case ResponsiveScreenType.watch:
      value = watch;
      break;
  }
  return value ?? orientationValue(defValue, defLandscape) ?? defValue;
}