From 8863427829f1912eff06c98dfa59b3e447495c3b Mon Sep 17 00:00:00 2001 From: tanlinxing Date: Thu, 21 Nov 2024 10:10:51 +0800 Subject: [PATCH] =?UTF-8?q?CFG=E9=87=8D=E6=96=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/dataAndDevice/controller.dart | 2 +- lib/pages/dataAndDevice/real_data.dart | 43 +++++++++++++------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/pages/dataAndDevice/controller.dart b/lib/pages/dataAndDevice/controller.dart index 5c90a4c..ce4dcc6 100644 --- a/lib/pages/dataAndDevice/controller.dart +++ b/lib/pages/dataAndDevice/controller.dart @@ -69,7 +69,7 @@ class RealDataController extends GetxController { final name = '桩点名称'.obs; final sid = '10.222'.obs; final times = 10.obs; -late final isClick = false.obs; +final isClicked = false.obs; late final lineDis = 110.0.obs; late final distance = 460.0.obs; diff --git a/lib/pages/dataAndDevice/real_data.dart b/lib/pages/dataAndDevice/real_data.dart index 651e86d..ed287d7 100644 --- a/lib/pages/dataAndDevice/real_data.dart +++ b/lib/pages/dataAndDevice/real_data.dart @@ -10,8 +10,7 @@ import '../aim_point/aimpoint_page.dart'; import 'controller.dart'; class RealDataContainer extends StatelessWidget { - final PlumRealDataController controller = Get.put(PlumRealDataController()); - final RealDataController realdatacontroller = Get.put(RealDataController()); + final RealDataController controller = Get.find(); @override Widget build(BuildContext context) { @@ -36,25 +35,27 @@ class RealDataContainer extends StatelessWidget { Positioned( bottom: 30, left: 35, - child: ElevatedButton( - style: ButtonStyle( - fixedSize: MaterialStateProperty.all(Size(200, 70)), - backgroundColor: MaterialStateProperty.all( - const Color.fromARGB(255, 226, 220, 220))), - child: Text( - realdatacontroller.isClick.value ? ' 暂停 ' : ' 开始 ', - style: TextStyle( - fontSize: 28, - color: realdatacontroller.isClick.value - ? Colors.red - : Colors.green), - ), - onPressed: () => { - realdatacontroller.isClick.value = - !realdatacontroller.isClick.value, - }, - ), - ) + child: Obx(() => ElevatedButton( + style: ButtonStyle( + fixedSize: MaterialStateProperty.all(Size(200, 70)), + backgroundColor: MaterialStateProperty.all( + const Color.fromARGB(255, 226, 220, 220), + ), + ), + child: Text( + controller.isClicked.value ? ' 暂停 ' : ' 开始 ', + style: TextStyle( + fontSize: 28, + color: controller.isClicked.value + ? Colors.red + : Colors.green, + ), + ), + onPressed: () { + controller.isClicked.value = !controller.isClicked.value; + }, + )), + ), ], ), );