fromBreakpoint static method

DeviceScreen fromBreakpoint(
  1. double deviceWidth,
  2. ScreenBreakpoints breakpoints
)

Implementation

static DeviceScreen fromBreakpoint(
  double deviceWidth,
  ScreenBreakpoints breakpoints,
) {
  if (breakpoints.isMinSBValue) {
    if (deviceWidth >= breakpoints.desktop!.value) {
      return DeviceScreen.desktop;
    }

    if (deviceWidth > breakpoints.tablet!.value) {
      return DeviceScreen.tablet;
    }

    return DeviceScreen.mobile;
  } else {
    if (deviceWidth <= breakpoints.mobile!.value) {
      return DeviceScreen.mobile;
    }

    if (deviceWidth <= breakpoints.tablet!.value) {
      return DeviceScreen.tablet;
    }

    return DeviceScreen.desktop;
  }
}