DeviceQueryData.detect constructor

DeviceQueryData.detect({
  1. BuildContext? context,
  2. MediaQueryData? mediaQueryData,
  3. double shortestSideBreakpoint = MAX_PHONE_SHORTEST_SIDE,
})

Creates a new DeviceQueryData depending on platform.

MAX_PHONE_SHORTEST_SIDE is used to detect phone or tablet devices

Note:

Implementation

factory DeviceQueryData.detect({
  BuildContext? context,
  MediaQueryData? mediaQueryData,
  double shortestSideBreakpoint = MAX_PHONE_SHORTEST_SIDE,
}) {
  assert(context != null || mediaQueryData != null);
  var type = DeviceType.unknown;

  if (kIsWeb) {
    type = DeviceType.web;
  } else if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
    type = DeviceType.desktop;
  } else {
    type = _getMobileType(
      context: context,
      mediaQueryData: mediaQueryData,
      shortestSideBreakpoint: shortestSideBreakpoint,
    );
  }

  return DeviceQueryData(deviceType: type);
}