getDeviceType function

DeviceType getDeviceType(
  1. Size size
)

Returns the DeviceScreenType that the application is currently running on

Implementation

DeviceType getDeviceType(Size size) {
  double deviceWidth = size.shortestSide;

  if (kIsWeb || Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
    deviceWidth = size.width;
  }

  // Replaces the defaults with the user defined definitions
  if (deviceWidth >= 1200) {
    return DeviceType.desktop;
  }

  // If no user defined definitions are passed through use the defaults
  if (deviceWidth >= 900) {
    return DeviceType.laptop;
  }

  if (deviceWidth >= 600) {
    return DeviceType.tablet;
  }

  return DeviceType.phone;
}