Rich text editor for Flutter
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.

57 lines
1.5 KiB

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart'
show kIsWeb, TargetPlatform, defaultTargetPlatform;
bool isWeb() {
return kIsWeb;
}
3 years ago
bool isMobile([TargetPlatform? targetPlatform]) {
if (isWeb()) return false;
3 years ago
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;
}
Future<bool> isIOSSimulator() async {
if (!isAppleOS()) {
return false;
}
3 years ago
final deviceInfo = DeviceInfoPlugin();
3 years ago
final osInfo = await deviceInfo.deviceInfo;
if (osInfo is IosDeviceInfo) {
3 years ago
final iosInfo = osInfo;
return !iosInfo.isPhysicalDevice;
}
return false;
}