This commit is contained in:
rustdesk 2022-04-18 17:01:45 +08:00
parent cbc25547ba
commit 384d51450c
2 changed files with 13 additions and 6 deletions

View File

@ -53,7 +53,7 @@ class PlatformFFI {
var a = name.toNativeUtf8();
var b = arg.toNativeUtf8();
var p = _getByName!(a, b);
assert(p != nullptr && p != null);
assert(p != nullptr);
var res = p.toDartString();
calloc.free(p);
calloc.free(a);
@ -86,7 +86,11 @@ class PlatformFFI {
.lookupFunction<Void Function(Pointer<RgbaFrame>), F4>('free_rgba');
_getRgba = dylib.lookupFunction<F5, F5>('get_rgba');
_dir = (await getApplicationDocumentsDirectory()).path;
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
try {
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
} catch (e) {
print(e);
}
String id = 'NA';
String name = 'Flutter';
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
@ -123,9 +127,9 @@ class PlatformFFI {
});
}
static invokeMethod(String method,[ dynamic arguments ]) async {
static invokeMethod(String method, [dynamic arguments]) async {
if (!isAndroid) return Future<bool>(() => false);
return await toAndroidChannel.invokeMethod(method,arguments);
return await toAndroidChannel.invokeMethod(method, arguments);
}
}

View File

@ -4,6 +4,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:image/image.dart' as img;
import 'package:zxing2/qrcode.dart';
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import '../common.dart';
import '../models/model.dart';
@ -130,7 +131,7 @@ class _ScanPageState extends State<ScanPage> {
void showServerSettingFromQr(String data) async {
backToHome();
await controller!.stopCamera();
await controller?.pauseCamera();
if (!data.startsWith('config=')) {
showToast('Invalid QR code');
return;
@ -140,7 +141,9 @@ class _ScanPageState extends State<ScanPage> {
var host = values['host'] != null ? values['host'] as String : '';
var key = values['key'] != null ? values['key'] as String : '';
var api = values['api'] != null ? values['api'] as String : '';
showServerSettingsWithValue(host, '', key, api);
Timer(Duration(milliseconds: 60), () {
showServerSettingsWithValue(host, '', key, api);
});
} catch (e) {
showToast('Invalid QR code');
}