forked from Nexus/nexus
parent
85bb653980
commit
4f3b77f9f3
3 changed files with 16 additions and 12 deletions
|
|
@ -54,8 +54,19 @@ import "package:path_provider/path_provider.dart";
|
|||
class ClientController extends AsyncNotifier<int> {
|
||||
@override
|
||||
Future<int> build() async {
|
||||
final path = "${(await getApplicationSupportDirectory()).path}/gomuks";
|
||||
final handle = await init(path);
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
final env = {
|
||||
"GOMUKS_ROOT": (await getApplicationSupportDirectory()).path,
|
||||
"GOMUKS_CACHE_HOME": (await getApplicationCacheDirectory()).path,
|
||||
};
|
||||
for (final MapEntry(:key, :value) in env.entries) {
|
||||
GomuksSetEnv(
|
||||
key.toNativeUtf8().cast<Char>(),
|
||||
value.toNativeUtf8().cast<Char>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
final handle = await Isolate.run(GomuksInit);
|
||||
|
||||
final callable =
|
||||
NativeCallable<
|
||||
|
|
@ -152,13 +163,6 @@ class ClientController extends AsyncNotifier<int> {
|
|||
throw Exception("GomuksStart returned error code $errorCode");
|
||||
}
|
||||
|
||||
Future<int> init(String path) => Isolate.run(
|
||||
() => GomuksInit(
|
||||
((Platform.isAndroid || Platform.isIOS) ? path.toNativeUtf8() : nullptr)
|
||||
.cast(),
|
||||
),
|
||||
);
|
||||
|
||||
Future<dynamic> callGomuksMethod(
|
||||
Map<String, dynamic> data,
|
||||
FutureOr<GomuksResponse> Function(int handle, GomuksBorrowedBuffer data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue