platform_util.dart 661 B

1234567891011121314151617181920212223242526
  1. import 'dart:io';
  2. /// 平台判断工具类
  3. class PlatformUtil {
  4. PlatformUtil._();
  5. static bool get isMacOS => Platform.isMacOS;
  6. static bool get isWindows => Platform.isWindows;
  7. static bool get isLinux => Platform.isLinux;
  8. static bool get isAndroid => Platform.isAndroid;
  9. static bool get isIOS => Platform.isIOS;
  10. /// 切换注释,就可以用来测试iOS平台的效果
  11. // static bool get isIOS => true;
  12. static bool get isFuchsia => Platform.isFuchsia;
  13. static bool get isMobile => Platform.isIOS || Platform.isAndroid;
  14. static bool get isDesktop =>
  15. PlatformUtil.isMacOS || PlatformUtil.isWindows || PlatformUtil.isLinux;
  16. }