mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -4,6 +4,7 @@ import 'dart:io';
|
||||
import 'dart:math' show Random;
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
@@ -18,13 +19,6 @@ abstract class Utils {
|
||||
|
||||
static const channel = MethodChannel(Constants.appName);
|
||||
|
||||
@pragma("vm:platform-const")
|
||||
static final bool isMobile = Platform.isAndroid || Platform.isIOS;
|
||||
|
||||
@pragma("vm:platform-const")
|
||||
static final bool isDesktop =
|
||||
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||
|
||||
static const jsonEncoder = JsonEncoder.withIndent(' ');
|
||||
|
||||
static Future<void> saveBytes2File({
|
||||
@@ -38,13 +32,13 @@ abstract class Utils {
|
||||
allowedExtensions: allowedExtensions,
|
||||
type: type,
|
||||
fileName: name,
|
||||
bytes: Utils.isDesktop ? null : bytes,
|
||||
bytes: PlatformUtils.isDesktop ? null : bytes,
|
||||
);
|
||||
if (path == null) {
|
||||
SmartDialog.showToast("取消保存");
|
||||
return;
|
||||
}
|
||||
if (Utils.isDesktop) {
|
||||
if (PlatformUtils.isDesktop) {
|
||||
await File(path).writeAsBytes(bytes);
|
||||
}
|
||||
SmartDialog.showToast("已保存");
|
||||
@@ -62,7 +56,7 @@ abstract class Utils {
|
||||
|
||||
static Future<bool> get isWiFi async {
|
||||
try {
|
||||
return Utils.isMobile &&
|
||||
return PlatformUtils.isMobile &&
|
||||
(await Connectivity().checkConnectivity()).contains(
|
||||
ConnectivityResult.wifi,
|
||||
);
|
||||
@@ -96,7 +90,7 @@ abstract class Utils {
|
||||
}
|
||||
|
||||
static Future<void> shareText(String text) async {
|
||||
if (Utils.isDesktop) {
|
||||
if (PlatformUtils.isDesktop) {
|
||||
copyText(text);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user