Merge branch 'feature/my' of http://1.95.137.212:57001/APP/FlutterApp into feature/my
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -25,6 +27,7 @@ class RemoteControlPage extends StatefulWidget {
|
||||
|
||||
class _RemoteControlPageState extends State<RemoteControlPage> {
|
||||
String _videoStreamUrl = "";
|
||||
StreamSubscription? _deviceStatusSubscription;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -33,8 +36,17 @@ class _RemoteControlPageState extends State<RemoteControlPage> {
|
||||
// 2. 隐藏状态栏和虚拟按键
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
||||
|
||||
// 🔥 关键:订阅 DeviceStatusBloc 的状态流
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<RemoteControlCubit>().startControlLoop();
|
||||
final remoteCubit = context.read<RemoteControlCubit>();
|
||||
final devicesCubit = context.read<DevicesCubit>();
|
||||
|
||||
remoteCubit.startControlLoop();
|
||||
// 🔥 关键:订阅 DeviceStatusBloc 的状态流
|
||||
remoteCubit.subscribeToDeviceStatus(devicesCubit.stream);
|
||||
|
||||
debugPrint('🚀 [遥控页面] 已启动控制循环和设备状态监听');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,6 +54,8 @@ class _RemoteControlPageState extends State<RemoteControlPage> {
|
||||
void dispose() {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
_deviceStatusSubscription?.cancel();
|
||||
context.read<RemoteControlCubit>().stopControlLoop();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user