isMobile and isDesktop return false on web

This commit is contained in:
Shawn 2023-01-01 12:26:38 -07:00
parent 099ae9893d
commit f74dc5bd68

View File

@ -8,9 +8,9 @@ class PlatformInfo {
static const _desktopPlatforms = [TargetPlatform.macOS, TargetPlatform.windows, TargetPlatform.linux]; static const _desktopPlatforms = [TargetPlatform.macOS, TargetPlatform.windows, TargetPlatform.linux];
static const _mobilePlatforms = [TargetPlatform.android, TargetPlatform.iOS]; static const _mobilePlatforms = [TargetPlatform.android, TargetPlatform.iOS];
static bool get isDesktop => _desktopPlatforms.contains(defaultTargetPlatform); static bool get isDesktop => _desktopPlatforms.contains(defaultTargetPlatform) && !kIsWeb;
static bool get isDesktopOrWeb => isDesktop || kIsWeb; static bool get isDesktopOrWeb => isDesktop || kIsWeb;
static bool get isMobile => _mobilePlatforms.contains(defaultTargetPlatform); static bool get isMobile => _mobilePlatforms.contains(defaultTargetPlatform) && !kIsWeb;
static double get pixelRatio => WidgetsBinding.instance.window.devicePixelRatio; static double get pixelRatio => WidgetsBinding.instance.window.devicePixelRatio;