mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-29 08:19:05 +08:00
temporary solution for Flutter catch Accessibility Input
This commit is contained in:
parent
49c2bf9616
commit
da4fc7f906
@ -1,3 +1,4 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
@ -217,3 +218,47 @@ String readableFileSize(double size) {
|
||||
return (size / G).toStringAsFixed(2) + " GB";
|
||||
}
|
||||
}
|
||||
|
||||
/// Flutter can't not catch PointerMoveEvent when size is 1
|
||||
/// This will happen in Android AccessibilityService Input
|
||||
/// android can't init dispatching size yet ,see: https://stackoverflow.com/questions/59960451/android-accessibility-dispatchgesture-is-it-possible-to-specify-pressure-for-a
|
||||
/// use this temporary solution until flutter or android fixes the bug
|
||||
class AccessibilityListener extends StatelessWidget {
|
||||
final Widget? child;
|
||||
static final offset = 100;
|
||||
|
||||
AccessibilityListener({this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Listener(
|
||||
onPointerDown: (evt) {
|
||||
if (evt.size == 1 && GestureBinding.instance != null) {
|
||||
GestureBinding.instance!.handlePointerEvent(PointerAddedEvent(
|
||||
pointer: evt.pointer + offset, position: evt.position));
|
||||
GestureBinding.instance!.handlePointerEvent(PointerDownEvent(
|
||||
pointer: evt.pointer + offset,
|
||||
size: 0.1,
|
||||
position: evt.position));
|
||||
}
|
||||
},
|
||||
onPointerUp: (evt) {
|
||||
if (evt.size == 1 && GestureBinding.instance != null) {
|
||||
GestureBinding.instance!.handlePointerEvent(PointerUpEvent(
|
||||
pointer: evt.pointer + offset,
|
||||
size: 0.1,
|
||||
position: evt.position));
|
||||
}
|
||||
},
|
||||
onPointerMove: (evt) {
|
||||
if (evt.size == 1 && GestureBinding.instance != null) {
|
||||
GestureBinding.instance!.handlePointerEvent(PointerMoveEvent(
|
||||
pointer: evt.pointer + offset,
|
||||
size: 0.1,
|
||||
delta: evt.delta,
|
||||
position: evt.position));
|
||||
}
|
||||
},
|
||||
child: child);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,13 @@ class App extends StatelessWidget {
|
||||
navigatorObservers: [
|
||||
FirebaseAnalyticsObserver(analytics: analytics),
|
||||
],
|
||||
builder: EasyLoading.init(),
|
||||
builder: isAndroid
|
||||
? (_, child) {
|
||||
return AccessibilityListener(
|
||||
child: FlutterEasyLoading(child: child),
|
||||
);
|
||||
}
|
||||
: EasyLoading.init(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user