dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.6 KiB
63 lines
1.6 KiB
import 'dart:io' show Platform; |
|
|
|
import 'package:device_info_plus/device_info_plus.dart'; |
|
import 'package:flutter/foundation.dart' |
|
show kIsWeb, TargetPlatform, defaultTargetPlatform; |
|
|
|
bool isWeb() { |
|
return kIsWeb; |
|
} |
|
|
|
bool isMobile([TargetPlatform? targetPlatform]) { |
|
if (isWeb()) return false; |
|
targetPlatform ??= defaultTargetPlatform; |
|
return {TargetPlatform.iOS, TargetPlatform.android}.contains(targetPlatform); |
|
} |
|
|
|
bool isDesktop([TargetPlatform? targetPlatform]) { |
|
if (isWeb()) return false; |
|
targetPlatform ??= defaultTargetPlatform; |
|
return {TargetPlatform.macOS, TargetPlatform.linux, TargetPlatform.windows} |
|
.contains(targetPlatform); |
|
} |
|
|
|
bool isKeyboardOS([TargetPlatform? targetPlatform]) { |
|
targetPlatform ??= defaultTargetPlatform; |
|
return isDesktop(targetPlatform) || targetPlatform == TargetPlatform.fuchsia; |
|
} |
|
|
|
bool isAppleOS([TargetPlatform? targetPlatform]) { |
|
if (isWeb()) return false; |
|
targetPlatform ??= defaultTargetPlatform; |
|
return { |
|
TargetPlatform.macOS, |
|
TargetPlatform.iOS, |
|
}.contains(targetPlatform); |
|
} |
|
|
|
bool isMacOS([TargetPlatform? targetPlatform]) { |
|
if (isWeb()) return false; |
|
targetPlatform ??= defaultTargetPlatform; |
|
return TargetPlatform.macOS == targetPlatform; |
|
} |
|
|
|
bool isFlutterTest() { |
|
if (isWeb()) return false; |
|
return Platform.environment.containsKey('FLUTTER_TEST'); |
|
} |
|
|
|
Future<bool> isIOSSimulator() async { |
|
if (!isAppleOS()) { |
|
return false; |
|
} |
|
|
|
final deviceInfo = DeviceInfoPlugin(); |
|
|
|
final osInfo = await deviceInfo.deviceInfo; |
|
|
|
if (osInfo is IosDeviceInfo) { |
|
final iosInfo = osInfo; |
|
return !iosInfo.isPhysicalDevice; |
|
} |
|
return false; |
|
}
|
|
|