import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'line_chart.dart'; import 'real_controller.dart'; import 'real_data.dart'; final RealController realController = Get.find(); class Real extends StatelessWidget { const Real({super.key}); @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; // 设备获取 return OrientationBuilder(builder: (context, orientation) { bool isPortrait = Orientation.portrait == orientation ? true : false; Widget space = const SizedBox( height: 5, width: 5, ); List children = [ RealData(), space, const Divider( height: 1.0, // 线条的高度 color: Colors.black, // 线条的颜色 ), space, // lineChart Expanded( flex: 1, child: Column( children: [ Expanded(child: RealChart()), Obx(() => Slider( value: realController.startIndex.toDouble(), onChanged: (newvalue) => realController.updateSlider(newvalue), min: 0, max: realController.processList.length.toDouble(), )), ], ), ) ]; if (isPortrait) { return Container( padding: const EdgeInsets.all(2), height: size.height - 4, child: Column(children: children)); } else { return Container( padding: const EdgeInsets.all(2), width: size.width - 4, child: Row( children: children, ), ); } }); } }