Save preferences to same directory to binary file on Windows

This commit is contained in:
2023-08-30 22:09:39 +08:00
parent 63b5e9f71e
commit 6f3a400ed8
12 changed files with 257 additions and 6 deletions

28
lib/platform/path.dart Normal file
View File

@@ -0,0 +1,28 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import '../utils.dart';
final Logger _log = Logger("platformPath");
class Path {
static const platform = MethodChannel("lifegpc.eh_downloader_flutter/path");
String? _currentExe;
bool _currentExeLoaded = false;
String? get currentExe => _currentExe;
Future<String?> getCurrentExe() async {
if (_currentExeLoaded) return _currentExe;
try {
final String result = await platform.invokeMethod("getCurrentExe");
_currentExe = result;
} on PlatformException catch (e) {
if (isWindows) {
_log.warning("Failed to get current exe path:", e);
}
}
_currentExeLoaded = true;
return _currentExe;
}
}