fix web and multi platform adaptation

This commit is contained in:
csf
2022-03-24 17:58:33 +08:00
parent 98d8689d7b
commit 8736d37605
7 changed files with 53 additions and 28 deletions

View File

@@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_hbb/pages/chat_page.dart';
import 'model.dart';
import 'native_model.dart';
class ChatModel with ChangeNotifier {
// -1作为客户端模式的id客户端模式下此id唯一
@@ -51,12 +50,12 @@ class ChatModel with ChangeNotifier {
if (message.text != null && message.text!.isNotEmpty) {
_messages[_currentID]?.add(message);
if (_currentID == clientModeID) {
PlatformFFI.setByName("chat_client_mode", message.text!);
FFI.setByName("chat_client_mode", message.text!);
} else {
final msg = Map()
..["id"] = _currentID
..["text"] = message.text!;
PlatformFFI.setByName("chat_server_mode", jsonEncode(msg));
FFI.setByName("chat_server_mode", jsonEncode(msg));
}
}
notifyListeners();

View File

@@ -24,7 +24,6 @@ class PlatformFFI {
static Pointer<RgbaFrame>? _lastRgbaFrame;
static String _dir = '';
static String _homeDir = '';
static int? _androidVersion;
static F2? _getByName;
static F3? _setByName;
static F4? _freeRgba;
@@ -49,8 +48,6 @@ class PlatformFFI {
return packageInfo.version;
}
static int? get androidVersion => _androidVersion;
static String getByName(String name, [String arg = '']) {
if (_getByName == null) return '';
var a = name.toNativeUtf8();
@@ -97,7 +94,7 @@ class PlatformFFI {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
name = '${androidInfo.brand}-${androidInfo.model}';
id = androidInfo.id.hashCode.toString();
_androidVersion = androidInfo.version.sdkInt;
androidVersion = androidInfo.version.sdkInt;
} else {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
name = iosInfo.utsname.machine;

View File

@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/models/native_model.dart';
import '../common.dart';
import '../pages/server_page.dart';
import 'model.dart';
@@ -71,7 +70,7 @@ class ServerModel with ChangeNotifier {
toggleInput(){
if(_inputOk){
PlatformFFI.invokeMethod("stop_input");
FFI.invokeMethod("stop_input");
}else{
showInputWarnAlert();
}