Advertisement
Guest User

Untitled

a guest
Mar 8th, 2023
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. GestureDetector(
  2. onTap: () async {
  3. String coord = '';
  4. String ngay_kiem_tra = await getCurrentDate();
  5. String img_ = await (data_select.home_page +
  6. ImgController.imageURL.value.toString());
  7. String query_img = '=IMAGE("' + img_.toString() + '", 2)';
  8. String device_info = await DeviceInfoZ.info();
  9. if (Platform.isAndroid || Platform.isIOS) {
  10. coord = await Permission_device.getUserLocation();
  11. }
  12. if (img_.toString() == '' || img_.toString() == null) {
  13. FormHelper.showMessage(
  14. context,
  15. "Đang tải hình ảnh ...",
  16. "Hình ảnh chưa sẵn sàng, cập nhật lại sau!",
  17. "OK",
  18. () {
  19. Navigator.of(context).pop();
  20. },
  21. );
  22. return;
  23. }
  24. final feedback = {
  25. SheetsColumn.msnv: msnvController.text.trim(),
  26. SheetsColumn.ngay_kiem_tra: ngay_kiem_tra,
  27. SheetsColumn.xuat_tuyen: xuatTuyen,
  28. SheetsColumn.phatquang: phatquang,
  29. SheetsColumn.nhanh_re: nhanh_reController.text.trim(),
  30. SheetsColumn.khoang_tru: khoang_truController.text.trim(),
  31. SheetsColumn.so_cay: so_cayController.text.trim(),
  32. SheetsColumn.ghi_chu: ghi_chuController.text.trim(),
  33. SheetsColumn.de_xuat: de_xuatController.text.trim(),
  34. SheetsColumn.khoang_cach:
  35. dropdownValue1 + '→' + dropdownValue2,
  36. SheetsColumn.binh_thuong: _character == 0 ? 'x' : '',
  37. SheetsColumn.nguy_hiem: _character == 1 ? 'x' : '',
  38. SheetsColumn.db_nguy_hiem: _character == 2 ? 'x' : '',
  39. SheetsColumn.image: query_img,
  40. SheetsColumn.device_info: device_info,
  41. SheetsColumn.location: coord,
  42. };
  43. try {
  44. // print(query_img);
  45. // test internet connection
  46. final result = await InternetAddress.lookup('google.com');
  47. if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
  48. // insert gg sheet
  49. await SheetsFlutter.insert('hanh_lang', [feedback]);
  50. // create in mysql
  51. if (ImgController.imageURL.value == '') {
  52. FormHelper.showMessage(
  53. context,
  54. "⚡ Thất bại! ⚡",
  55. "Ảnh không được để trống!",
  56. "OK",
  57. () {
  58. Get.back();
  59. },
  60. );
  61. return;
  62. }
  63. await _taskController.createTask(
  64. type: 'hanh_lang',
  65. msnv: msnvController.text.trim(),
  66. xuat_tuyen: xuatTuyen,
  67. muc_do_index: _character,
  68. tu_tru_den_tru: nhanh_reController.text.trim() +
  69. '→' +
  70. khoang_truController.text.trim(),
  71. note_nv: ghi_chuController.text.trim(),
  72. de_xuat: de_xuatController.text.trim(),
  73. pa_phat_quang: phatquang,
  74. image: ImgController.imageURL.value.toString(),
  75. so_cay: so_cayController.text.trim(),
  76. khoang_cach: dropdownValue1 + '→' + dropdownValue2,
  77. loai_khiem_khuyet: '',
  78. noi_dung_kk: '',
  79. vat_tu: '',
  80. bien_phap_at: '',
  81. );
  82. // await SheetsFlutter.init();
  83. FormHelper.showMessage(
  84. context,
  85. "⚡ Thông báo ⚡",
  86. "Bạn đã gửi dữ liệu thành công!",
  87. "OK",
  88. () {
  89. Get.back();
  90. },
  91. );
  92. }
  93. } on SocketException catch (_) {
  94. FormHelper.showMessage(
  95. context,
  96. "⚡ Thông báo ⚡",
  97. "Không có kết nối internet, không thể gửi được dữ liệu. Vui lòng thử lại sau!",
  98. "OK",
  99. () {
  100. Get.back();
  101. },
  102. );
  103. }
  104. },
  105. child: Container(
  106. child: Container(
  107. height: input_h * 0.05,
  108. width: input_w,
  109. color: Colors.blue,
  110. child: Center(child: Text("Cập nhật")),
  111. ),
  112. padding: const EdgeInsets.only(bottom: 20),
  113. ),
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement