code enhancement

Signed-off-by: Hamidi Mohammed <mr.hammiddi@gmail.com>
This commit is contained in:
Hamidi Mohammed 2022-06-19 17:15:37 +01:00
parent 086c8e43d7
commit 5a051ae3b6
8 changed files with 17 additions and 27 deletions

View File

@ -233,7 +233,7 @@ class AccessibilityListener extends StatelessWidget {
} }
}, },
onPointerUp: (evt) { onPointerUp: (evt) {
if (evt.size == 1 && GestureBinding.instance != null) { if (evt.size == 1) {
GestureBinding.instance.handlePointerEvent(PointerUpEvent( GestureBinding.instance.handlePointerEvent(PointerUpEvent(
pointer: evt.pointer + offset, pointer: evt.pointer + offset,
size: 0.1, size: 0.1,
@ -243,7 +243,7 @@ class AccessibilityListener extends StatelessWidget {
} }
}, },
onPointerMove: (evt) { onPointerMove: (evt) {
if (evt.size == 1 && GestureBinding.instance != null) { if (evt.size == 1) {
GestureBinding.instance.handlePointerEvent(PointerMoveEvent( GestureBinding.instance.handlePointerEvent(PointerMoveEvent(
pointer: evt.pointer + offset, pointer: evt.pointer + offset,
size: 0.1, size: 0.1,

View File

@ -593,15 +593,7 @@ class FileFetcher {
tryCompleteTask(String? msg, String? isLocalStr) { tryCompleteTask(String? msg, String? isLocalStr) {
if (msg == null || isLocalStr == null) return; if (msg == null || isLocalStr == null) return;
late final isLocal;
late final tasks; late final tasks;
if (isLocalStr == "true") {
isLocal = true;
} else if (isLocalStr == "false") {
isLocal = false;
} else {
return;
}
try { try {
final fd = FileDirectory.fromJson(jsonDecode(msg)); final fd = FileDirectory.fromJson(jsonDecode(msg));
if (fd.id > 0) { if (fd.id > 0) {

View File

@ -21,7 +21,6 @@ typedef F2 = Pointer<Utf8> Function(Pointer<Utf8>, Pointer<Utf8>);
typedef F3 = void Function(Pointer<Utf8>, Pointer<Utf8>); typedef F3 = void Function(Pointer<Utf8>, Pointer<Utf8>);
class PlatformFFI { class PlatformFFI {
static Pointer<RgbaFrame>? _lastRgbaFrame;
static String _dir = ''; static String _dir = '';
static String _homeDir = ''; static String _homeDir = '';
static F2? _getByName; static F2? _getByName;

View File

@ -1,3 +1,5 @@
// ignore_for_file: avoid_web_libraries_in_flutter
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:js'; import 'dart:js';

View File

@ -100,8 +100,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
: InkWell( : InkWell(
onTap: () async { onTap: () async {
final url = _updateUrl + '.apk'; final url = _updateUrl + '.apk';
if (await canLaunch(url)) { if (await canLaunchUrl(Uri.parse(url))) {
await launch(url); await launchUrl(Uri.parse(url));
} }
}, },
child: Container( child: Container(

View File

@ -126,7 +126,7 @@ class _RemotePageState extends State<RemotePage> {
common < oldValue.length && common < oldValue.length &&
common < newValue.length && common < newValue.length &&
newValue[common] == oldValue[common]; newValue[common] == oldValue[common];
++common); ++common) {}
for (i = 0; i < oldValue.length - common; ++i) { for (i = 0; i < oldValue.length - common; ++i) {
FFI.inputKey('VK_BACK'); FFI.inputKey('VK_BACK');
} }

View File

@ -68,8 +68,8 @@ class _SettingsState extends State<SettingsPage> {
tiles: [ tiles: [
SettingsTile.navigation( SettingsTile.navigation(
onPressed: (context) async { onPressed: (context) async {
if (await canLaunch(url)) { if (await canLaunchUrl(Uri.parse(url))) {
await launch(url); await launchUrl(Uri.parse(url));
} }
}, },
title: Text(translate("Version: ") + version), title: Text(translate("Version: ") + version),
@ -105,8 +105,8 @@ void showAbout() {
InkWell( InkWell(
onTap: () async { onTap: () async {
const url = 'https://rustdesk.com/'; const url = 'https://rustdesk.com/';
if (await canLaunch(url)) { if (await canLaunchUrl(Uri.parse(url))) {
await launch(url); await launchUrl(Uri.parse(url));
} }
}, },
child: Padding( child: Padding(
@ -149,7 +149,7 @@ fetch('http://localhost:21114/api/login', {
'uuid': FFI.getByName('uuid') 'uuid': FFI.getByName('uuid')
}; };
try { try {
final response = await http.post(Uri.parse('${url}/api/login'), final response = await http.post(Uri.parse('$url/api/login'),
headers: {"Content-Type": "application/json"}, body: json.encode(body)); headers: {"Content-Type": "application/json"}, body: json.encode(body));
return parseResp(response.body); return parseResp(response.body);
} catch (e) { } catch (e) {
@ -186,7 +186,7 @@ void refreshCurrentUser() async {
'uuid': FFI.getByName('uuid') 'uuid': FFI.getByName('uuid')
}; };
try { try {
final response = await http.post(Uri.parse('${url}/api/currentUser'), final response = await http.post(Uri.parse('$url/api/currentUser'),
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": "Bearer $token" "Authorization": "Bearer $token"
@ -212,7 +212,7 @@ void logout() async {
'uuid': FFI.getByName('uuid') 'uuid': FFI.getByName('uuid')
}; };
try { try {
await http.post(Uri.parse('${url}/api/logout'), await http.post(Uri.parse('$url/api/logout'),
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": "Bearer $token" "Authorization": "Bearer $token"
@ -242,7 +242,7 @@ String getUrl() {
url = 'http://${tmp[0]}:$port'; url = 'http://${tmp[0]}:$port';
} }
} else { } else {
url = 'http://${url}:21114'; url = 'http://$url:21114';
} }
} }
} }

View File

@ -594,10 +594,7 @@ class _TapTracker {
required this.entry, required this.entry,
required Duration doubleTapMinTime, required Duration doubleTapMinTime,
required this.gestureSettings, required this.gestureSettings,
}) : assert(doubleTapMinTime != null), }) : pointer = event.pointer,
assert(event != null),
assert(event.buttons != null),
pointer = event.pointer,
_initialGlobalPosition = event.position, _initialGlobalPosition = event.position,
initialButtons = event.buttons, initialButtons = event.buttons,
_doubleTapMinTimeCountdown = _doubleTapMinTimeCountdown =
@ -643,7 +640,7 @@ class _TapTracker {
/// CountdownZoned tracks whether the specified duration has elapsed since /// CountdownZoned tracks whether the specified duration has elapsed since
/// creation, honoring [Zone]. /// creation, honoring [Zone].
class _CountdownZoned { class _CountdownZoned {
_CountdownZoned({required Duration duration}) : assert(duration != null) { _CountdownZoned({required Duration duration}) {
Timer(duration, _onTimeout); Timer(duration, _onTimeout);
} }