image_detecting_dialog.dart 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import '../index.dart';
  5. class ImageDetectingDialog extends GetView<FacialRecognitionController> {
  6. const ImageDetectingDialog({Key? key}) : super(key: key);
  7. @override
  8. Widget build(BuildContext context) {
  9. return Obx(
  10. () {
  11. if (controller.state.processingImageLocalPath.isEmpty) {
  12. return Container();
  13. }
  14. // 是否需要左右翻转
  15. final needMirror = controller.state.isUsingFrontCamera;
  16. return Center(
  17. child: Stack(
  18. children: [
  19. ModalBarrier(
  20. color: Colors.black.withOpacity(0.5),
  21. dismissible: false,
  22. ),
  23. Center(
  24. child: Container(
  25. width: 850,
  26. height: 600,
  27. decoration: BoxDecoration(
  28. color: Colors.white,
  29. borderRadius: BorderRadius.circular(10),
  30. ),
  31. clipBehavior: Clip.antiAlias,
  32. padding: const EdgeInsets.all(40),
  33. child: Column(
  34. children: [
  35. Stack(
  36. children: [
  37. Center(
  38. child: Container(
  39. decoration: BoxDecoration(
  40. borderRadius: BorderRadius.circular(10),
  41. ),
  42. clipBehavior: Clip.antiAlias,
  43. child: Transform(
  44. alignment: Alignment.center,
  45. transform: Matrix4.rotationY(
  46. needMirror ? 3.1415926 : 0),
  47. child: Image(
  48. image: FileImage(
  49. File(controller
  50. .state.processingImageLocalPath),
  51. ),
  52. fit: BoxFit.cover,
  53. ),
  54. ),
  55. ),
  56. ),
  57. ],
  58. ),
  59. const SizedBox(height: 40),
  60. Expanded(
  61. child: Row(
  62. mainAxisAlignment: MainAxisAlignment.center,
  63. children: const [
  64. SizedBox(
  65. height: 20,
  66. width: 20,
  67. child: CircularProgressIndicator(
  68. valueColor:
  69. AlwaysStoppedAnimation<Color>(Colors.blue),
  70. ),
  71. ),
  72. SizedBox(
  73. width: 20,
  74. ),
  75. Text(
  76. '人脸信息识别中,请稍后...',
  77. style: TextStyle(
  78. fontSize: 16, color: Colors.black54),
  79. ),
  80. ],
  81. ),
  82. ),
  83. ],
  84. ),
  85. ),
  86. ),
  87. // 旋转的 loading
  88. ],
  89. ),
  90. );
  91. },
  92. );
  93. }
  94. }