Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GestureDetector(
- onTap: () async {
- String coord = '';
- String ngay_kiem_tra = await getCurrentDate();
- String img_ = await (data_select.home_page +
- ImgController.imageURL.value.toString());
- String query_img = '=IMAGE("' + img_.toString() + '", 2)';
- String device_info = await DeviceInfoZ.info();
- if (Platform.isAndroid || Platform.isIOS) {
- coord = await Permission_device.getUserLocation();
- }
- if (img_.toString() == '' || img_.toString() == null) {
- FormHelper.showMessage(
- context,
- "Đang tải hình ảnh ...",
- "Hình ảnh chưa sẵn sàng, cập nhật lại sau!",
- "OK",
- () {
- Navigator.of(context).pop();
- },
- );
- return;
- }
- final feedback = {
- SheetsColumn.msnv: msnvController.text.trim(),
- SheetsColumn.ngay_kiem_tra: ngay_kiem_tra,
- SheetsColumn.xuat_tuyen: xuatTuyen,
- SheetsColumn.phatquang: phatquang,
- SheetsColumn.nhanh_re: nhanh_reController.text.trim(),
- SheetsColumn.khoang_tru: khoang_truController.text.trim(),
- SheetsColumn.so_cay: so_cayController.text.trim(),
- SheetsColumn.ghi_chu: ghi_chuController.text.trim(),
- SheetsColumn.de_xuat: de_xuatController.text.trim(),
- SheetsColumn.khoang_cach:
- dropdownValue1 + '→' + dropdownValue2,
- SheetsColumn.binh_thuong: _character == 0 ? 'x' : '',
- SheetsColumn.nguy_hiem: _character == 1 ? 'x' : '',
- SheetsColumn.db_nguy_hiem: _character == 2 ? 'x' : '',
- SheetsColumn.image: query_img,
- SheetsColumn.device_info: device_info,
- SheetsColumn.location: coord,
- };
- try {
- // print(query_img);
- // test internet connection
- final result = await InternetAddress.lookup('google.com');
- if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
- // insert gg sheet
- await SheetsFlutter.insert('hanh_lang', [feedback]);
- // create in mysql
- if (ImgController.imageURL.value == '') {
- FormHelper.showMessage(
- context,
- "⚡ Thất bại! ⚡",
- "Ảnh không được để trống!",
- "OK",
- () {
- Get.back();
- },
- );
- return;
- }
- await _taskController.createTask(
- type: 'hanh_lang',
- msnv: msnvController.text.trim(),
- xuat_tuyen: xuatTuyen,
- muc_do_index: _character,
- tu_tru_den_tru: nhanh_reController.text.trim() +
- '→' +
- khoang_truController.text.trim(),
- note_nv: ghi_chuController.text.trim(),
- de_xuat: de_xuatController.text.trim(),
- pa_phat_quang: phatquang,
- image: ImgController.imageURL.value.toString(),
- so_cay: so_cayController.text.trim(),
- khoang_cach: dropdownValue1 + '→' + dropdownValue2,
- loai_khiem_khuyet: '',
- noi_dung_kk: '',
- vat_tu: '',
- bien_phap_at: '',
- );
- // await SheetsFlutter.init();
- FormHelper.showMessage(
- context,
- "⚡ Thông báo ⚡",
- "Bạn đã gửi dữ liệu thành công!",
- "OK",
- () {
- Get.back();
- },
- );
- }
- } on SocketException catch (_) {
- FormHelper.showMessage(
- context,
- "⚡ Thông báo ⚡",
- "Không có kết nối internet, không thể gửi được dữ liệu. Vui lòng thử lại sau!",
- "OK",
- () {
- Get.back();
- },
- );
- }
- },
- child: Container(
- child: Container(
- height: input_h * 0.05,
- width: input_w,
- color: Colors.blue,
- child: Center(child: Text("Cập nhật")),
- ),
- padding: const EdgeInsets.only(bottom: 20),
- ),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement