camera_ui.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import 'package:camera/camera.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import '../index.dart';
  5. import 'widgets.dart';
  6. /// 摄像头预览
  7. class CameraUI extends GetView<HardwareDetectionController> {
  8. @override
  9. Widget build(BuildContext context) {
  10. return Obx(
  11. () {
  12. if (controller.state.cameraList.isEmpty) {
  13. return Container();
  14. }
  15. return ExpandableContainer(
  16. expanded: controller.state.isDisplayCameraWindow,
  17. child: controller.state.isDisplayCameraWindow
  18. ? CameraPreview(controller.cameraController)
  19. : Container(
  20. decoration: BoxDecoration(
  21. border: Border.all(color: Colors.grey[300]!),
  22. borderRadius: BorderRadius.circular(5),
  23. color: Colors.grey[200],
  24. ),
  25. child: Center(
  26. child: Icon(
  27. Icons.photo_camera_outlined,
  28. color: Colors.black54,
  29. ),
  30. ),
  31. ),
  32. );
  33. },
  34. );
  35. }
  36. }