修复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() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:cc_ui_kit/cc_ui_kit.dart';
|
||||
import 'package:cc_ui_kit/cc_ui_kit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
@@ -46,10 +46,12 @@ class _RightJoystickAreaState extends State<RightJoystickArea> {
|
||||
context.read<RemoteControlCubit>().updateOriginX(finalX);
|
||||
},
|
||||
onPress: _triggerVibration,
|
||||
onPanEnd: () {
|
||||
debugPrint('🕹️ [右摇杆] 松手,强制X=0');
|
||||
onPanEnd: () async {
|
||||
debugPrint('🕹️ [右摇杆] 松手,强制 X=0, Y=0');
|
||||
_lastX = 0;
|
||||
context.read<RemoteControlCubit>().updateOriginX(0);
|
||||
|
||||
// 🔥 使用安全方法,一次性清零双轴,确保只发送 (X=0, Y=0)
|
||||
await context.read<RemoteControlCubit>().stopAllMovement();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user