setScreenSize static method

void setScreenSize(
  1. BoxConstraints constraints,
  2. Orientation currentOrientation
)

Sets the Screen's size and Device's Orientation, BoxConstraints, Height, and Width

Implementation

static void setScreenSize(
    BoxConstraints constraints, Orientation currentOrientation) {
  // Sets boxconstraints and orientation
  boxConstraints = constraints;
  orientation = currentOrientation;

  // Sets screen width and height
  if (orientation == Orientation.portrait|| kIsWeb) {
    width = boxConstraints.maxWidth;
    height = boxConstraints.maxHeight;
  } else {
    width = boxConstraints.maxHeight;
    height = boxConstraints.maxWidth;
  }

  // Sets ScreenType
  if (kIsWeb) {
    deviceType = DeviceType.web;
  } else if (Platform.isAndroid || Platform.isIOS) {
    if ((orientation == Orientation.portrait && width < 600) ||
        (orientation == Orientation.landscape && height < 600)) {
      deviceType = DeviceType.mobile;
    } else {
      deviceType = DeviceType.tablet;
    }
  } else if (Platform.isMacOS) {
    deviceType = DeviceType.mac;
  } else if (Platform.isWindows) {
    deviceType = DeviceType.windows;
  } else if (Platform.isLinux) {
    deviceType = DeviceType.linux;
  } else {
    deviceType = DeviceType.fuchsia;
  }
}