dialog_ecg_image.dart 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. class EcgImageDialog extends StatelessWidget {
  4. const EcgImageDialog({Key? key, required this.image}) : super(key: key);
  5. final Image image;
  6. // 主视图
  7. Widget _buildView() {
  8. const designWidth = 1280.0; // 设计尺寸宽度:1280
  9. final width = Get.width;
  10. final scale = width / designWidth; // 计算缩放比例
  11. final ScrollController scrollController = ScrollController();
  12. return Container(
  13. width: Get.width * 0.9 / scale,
  14. height: 240 * 3,
  15. decoration: BoxDecoration(
  16. color: Colors.white,
  17. borderRadius: BorderRadius.circular(10),
  18. ),
  19. clipBehavior: Clip.antiAlias,
  20. child: Column(
  21. children: [
  22. _buildHead(),
  23. Expanded(
  24. child: Scrollbar(
  25. thumbVisibility: true,
  26. thickness: 10,
  27. radius: const Radius.circular(10),
  28. controller: scrollController,
  29. child: SingleChildScrollView(
  30. controller: scrollController,
  31. padding: const EdgeInsets.only(left: 10, right: 10, bottom: 20),
  32. physics: const BouncingScrollPhysics(),
  33. scrollDirection: Axis.horizontal,
  34. child: Center(
  35. child: image,
  36. ),
  37. ),
  38. ),
  39. ),
  40. ],
  41. ),
  42. );
  43. }
  44. // Widget displayImage(String base64Url) {
  45. // // 去掉"data:image/png;base64,"前缀
  46. // String base64Image = base64Url.split(',').last;
  47. // // 解码Base64字符串为字节数组
  48. // Uint8List imageData = base64Decode(base64Image);
  49. // return Image.memory(
  50. // imageData,
  51. // fit: BoxFit.cover, // 根据需要设置适当的fit属性
  52. // );
  53. // }
  54. @override
  55. Widget build(BuildContext context) {
  56. return Dialog(
  57. child: _buildView(),
  58. );
  59. }
  60. /// 构建弹窗顶部,右侧显示关闭按钮
  61. Widget _buildHead() {
  62. return SizedBox(
  63. height: 50,
  64. child: Row(
  65. mainAxisAlignment: MainAxisAlignment.end,
  66. children: [
  67. IconButton(
  68. onPressed: () => Get.back(),
  69. icon: const Icon(
  70. Icons.close,
  71. size: 30,
  72. ),
  73. ),
  74. ],
  75. ),
  76. );
  77. }
  78. }