修复emit异步导致的竞态+tcp缓冲取挤压+网络堵塞+定时器恢复的造成归0被吞的情况
完成APP端释放权限的接口的集成和数据返回获取
This commit is contained in:
@@ -50,11 +50,13 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
|
||||
},
|
||||
onPress: () {
|
||||
_isTouching = true;
|
||||
debugPrint('onPress');
|
||||
_triggerVibration();
|
||||
},
|
||||
onPanEnd: () {
|
||||
onPanEnd: () async {
|
||||
// 🔥 松手 100% 归零
|
||||
_stopJoystick();
|
||||
debugPrint('onPanEnd');
|
||||
await _stopJoystick();
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -73,11 +75,13 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
|
||||
}
|
||||
|
||||
// 统一停车方法(万能保险)
|
||||
void _stopJoystick() {
|
||||
Future<void> _stopJoystick() async {
|
||||
_isTouching = false;
|
||||
_lastSentY = 0;
|
||||
debugPrint('✅ 摇杆已停止 -> 强制 Y=0 停车');
|
||||
context.read<RemoteControlCubit>().updateOriginY(0);
|
||||
debugPrint('✅ 摇杆已停止 -> 强制 X=0, Y=0 停车');
|
||||
|
||||
// 🔥 使用安全方法,一次性清零双轴,确保只发送 (X=0, Y=0)
|
||||
await context.read<RemoteControlCubit>().stopAllMovement();
|
||||
}
|
||||
|
||||
void _triggerVibration() {
|
||||
|
||||
Reference in New Issue
Block a user