view.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'index.dart';
  4. class EcgView extends GetView<EcgViewController> {
  5. const EcgView({Key? key, required this.width, required this.height})
  6. : super(key: key);
  7. final double width;
  8. final double height;
  9. // 主视图
  10. Widget _buildView() {
  11. return Center(
  12. child: ClipRect(
  13. child: CustomPaint(
  14. foregroundPainter: EcgPainter(
  15. newPoints: controller.newPointsToDraw,
  16. oldPoints: controller.oldPointsToDraw,
  17. xDataCount: controller.xDataCount,
  18. yMax: 300,
  19. ),
  20. painter: GridBackgroundPainter(3 * 25),
  21. size: Size(width, height),
  22. ),
  23. ),
  24. );
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return GetBuilder<EcgViewController>(
  29. init: EcgViewController(),
  30. id: "ecg_view",
  31. builder: (_) {
  32. return GestureDetector(
  33. onTap: () => controller.openFullScreenDialog(),
  34. child: Center(
  35. child: _buildView(),
  36. ),
  37. );
  38. },
  39. );
  40. }
  41. }