DeviceQueryData.detect constructor
DeviceQueryData.detect({
- BuildContext? context,
- MediaQueryData? mediaQueryData,
- 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:
- DeviceType.watch and DeviceType.tv are not supported.
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);
}