import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart' as path; import 'package:flutter_map/flutter_map.dart'; import 'package:image_picker/image_picker.dart'; import 'package:latlong2/latlong.dart' as latlong; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tower_app/Screens/Menu/Survey/getdetailtsurvey_post.dart'; import 'package:tower_app/Screens/Menu/Survey/sendSurvey_post.dart'; import 'package:tower_app/Screens/Menu/Survey/surveylist_screen.dart'; import 'package:tower_app/Screens/Settings/RequestHttp/getDetail_post.dart'; import 'dart:developer' as logDev; import '../../background.dart'; import '../Canvasing/canvasingDetail_screen.dart'; TextEditingController isiDesaTeksController = TextEditingController(); TextEditingController isiKecamatanTeksController = TextEditingController(); TextEditingController isiKabupatenTeksController = TextEditingController(); TextEditingController isiProvinsiTeksController = TextEditingController(); TextEditingController isiJumlahPendudukTeksController = TextEditingController(); TextEditingController isiSignal2TeksController = TextEditingController(); TextEditingController isiSignal3TeksController = TextEditingController(); TextEditingController isiSignal4TeksController = TextEditingController(); TextEditingController isiCatatanTeksController = TextEditingController(); class DetailSurveyScreen extends StatefulWidget { const DetailSurveyScreen({Key? key}) : super(key: key); @override State createState() => _DetailSurveyScreen(); } class _DetailSurveyScreen extends State { bool visibleNamaDesa = true; bool visibleEditDesa = true; bool visibleFormDesa = false; bool visibleNamaKecamatan = true; bool visibleEditKecamatan = true; bool visibleFormKecamatan = false; bool visibleNamaKabupaten = true; bool visibleEditKabupaten = true; bool visibleFormKabupaten = false; bool visibleNamaProvinsi = true; bool visibleEditProvinsi = true; bool visibleFormProvinsi = false; final List _jenisTempat = []; final List _km = []; final List _ambilFoto = []; File? _imagePath; final List _pathFoto = []; final List _base64Foto = []; latlong.LatLng point = latlong.LatLng(-6.183580253674716, 106.93103973792664); late Position position; MapController _mapController = MapController(); late String titik; late String survey_name; late String nama_desa, nama_kecamatan, nama_kabupaten, nama_provinsi, posisi, signal2G, signal3G, signal4G, catatan; late int jumlah_penduduk; initState(){ isiDesaTeksController.clear(); isiKecamatanTeksController.clear(); isiKabupatenTeksController.clear(); isiProvinsiTeksController.clear(); isiJumlahPendudukTeksController.clear(); isiSignal2TeksController.clear(); isiSignal3TeksController.clear(); isiSignal4TeksController.clear(); isiCatatanTeksController.clear(); survey_name = "Survey"; nama_desa = ""; nama_kecamatan = ""; nama_kabupaten = ""; nama_provinsi = ""; posisi = ""; signal2G = ""; signal3G = ""; signal4G = ""; catatan = ""; jumlah_penduduk = 0; titik = ""; WidgetsBinding.instance.addPostFrameCallback((_) { getSurveyName(); //getDetailSurvey(); }); super.initState(); } getSurveyName() async { ProgressDialog loading = ProgressDialog(context); loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true); loading.style( message: 'Please Wait .....', borderRadius: 3, backgroundColor: Colors.white, progressWidget: CircularProgressIndicator(), elevation: 10.0, padding: EdgeInsets.all(10), insetAnimCurve: Curves.easeInOut, progress: 0.0, maxProgress: 100.0, progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400), messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600)); await loading.show(); final SharedPreferences prefs = await SharedPreferences.getInstance(); survey_name = prefs.getString('nameDetail')!; logDev.log(survey_name, name: "Nama Survey"); getDetailSurvey(); } getDetailSurvey() async { ProgressDialog loading = ProgressDialog(context); loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true); loading.style( message: 'Please Wait .....', borderRadius: 3, backgroundColor: Colors.white, progressWidget: CircularProgressIndicator(), elevation: 10.0, padding: EdgeInsets.all(10), insetAnimCurve: Curves.easeInOut, progress: 0.0, maxProgress: 100.0, progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400), messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600)); final SharedPreferences prefs = await SharedPreferences.getInstance(); int? idDetail = prefs.getInt('idDetail'); GetDetailSurvey_Post.connectToAPI(idDetail!).then((valueResult) async { Map object = jsonDecode(valueResult); String status = object['result']['status'].toString(); if (status.contains("failed")) { await loading.hide(); alertDialogFailedRetrievedData(context); } else if (status.contains("success")) { logDev.log(status, name: "SUCCeSS?"); //List allData = object['result']['data']; setState(() { nama_desa = object['result']['data']['desa'].toString(); logDev.log(nama_desa, name:"NAMA DESA?"); nama_kecamatan = object['result']['data']['kecamatan'].toString(); nama_kabupaten = object['result']['data']['kabupaten'].toString(); nama_provinsi = object['result']['data']['provinsi'].toString(); jumlah_penduduk = object['result']['data']['jumlah_penduduk']; posisi = object['result']['data']['posisi'].toString(); signal2G = object['result']['data']['signal_2G'].toString(); signal3G = object['result']['data']['signal_3G'].toString(); signal4G = object['result']['data']['signal_4G'].toString(); catatan = object['result']['data']['catatan'].toString(); point = latlong.LatLng(double.parse(posisi.split(",")[0]), double.parse(posisi.split(",")[1])); }); } await loading.hide(); }); } @override Widget build(BuildContext context) { var size = MediaQuery.sizeOf(context); return Scaffold( body: SingleChildScrollView( child: Column( children: [ Stack( children: [ WavyHeader(), Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height/6 - 20), padding: EdgeInsets.fromLTRB(20, 5, 25, 5), child: Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( //'Survey\t\t', "Detail Survey\t\t", maxLines: 2, style: GoogleFonts.luckiestGuy( fontSize: 28, color: Color(0xFF4858A7), fontStyle: FontStyle.italic, ), ), Image.asset("assets/icons/menu/survey_3.png", width: 40, height: 40, ), ], )), SafeArea( child: Container( width: MediaQuery.of(context).size.width, margin: EdgeInsets.only( top: MediaQuery.of(context).size.height / 5, left: 10, right: 10, bottom : 15, ), child: Column( children: [ Container( child: Card( elevation: 10, child: Container( decoration: BoxDecoration( color: Color(0XFFFAF7EE), borderRadius: BorderRadius.circular(10)), child: Column( children: [ Container( margin: EdgeInsets.only( left: 10, right: 10, top: 15, bottom: 10), child: Text(survey_name, style: GoogleFonts.ubuntu(fontSize: 19, fontWeight: FontWeight.bold, /*decoration: TextDecoration.underline*/ decorationStyle: TextDecorationStyle.dashed),), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Desa', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( nama_desa, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Kecamatan', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( nama_kecamatan, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Kabupaten', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( nama_kabupaten, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Provinsi', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( nama_provinsi, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Jumlah Penduduk', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( jumlah_penduduk.toString(), style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Posisi', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold), )), Container( height: size.height*0.4, width: size.width, margin: EdgeInsets.only(top: 2), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5) ), child: Stack( children:[ FlutterMap( mapController: _mapController, options: new MapOptions( onTap: (p, point) async {}, center: point, zoom: 15), children: [ TileLayer( minZoom: 1, maxZoom: 22, maxNativeZoom: 18, minNativeZoom: 1, backgroundColor: Colors.black54, urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c'], ), MarkerLayer(markers: [ Marker( width: 135, height: 135, point: point, builder: (ctx) => Container( child: Icon( Icons.location_on, color: Colors.red, ), )) ]) ], ), /*Container( alignment: AlignmentDirectional.bottomEnd, child: Container( margin: EdgeInsets.only(bottom: 10), *//*margin: EdgeInsets.fromLTRB(10, 15, 0, (size.height*0.4) + 15),*//* child: RawMaterialButton( onPressed: () { setState(() { updatePosition(); }); }, elevation: 5.0, fillColor: Colors.white, child: Image.asset('assets/images/location1.png', height: 35, width: 35), padding: EdgeInsets.all(5.0), shape: CircleBorder(), ), ), ),*/] ) ), ], ), ), Container( margin: EdgeInsets.only( left: 10, right: 10, top: 5), child:Align( alignment: Alignment.center, child: Text( posisi, overflow: TextOverflow.fade, softWrap: true, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold), ) ) ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Signal 2G (dBm)', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( signal2G, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Signal 3G (dBm)', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( signal3G, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Signal 4G (dBm)', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( signal4G, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Tempat Keramaian (Contoh: Sekolah, Pasar, dll)', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold), ), ), ListView.builder( shrinkWrap: true, itemCount: _jenisTempat.length, itemBuilder: (context, i) { return Padding( padding: const EdgeInsets.only(top: 2), child: Row( children: [ Expanded( flex: 7, child: Container( padding: const EdgeInsets.symmetric(horizontal: 10), //height: 60, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5), ), child: TextFormField( controller: _jenisTempat[i], autofocus: false, style: const TextStyle(color: Colors.black), decoration: const InputDecoration( border: InputBorder.none, hintText: "Jenis Tempat", hintStyle: TextStyle( color: Color.fromARGB(255, 132, 140, 155)), ), ), ), ), SizedBox(width: 5), Expanded( flex: 3, child: Container( padding: const EdgeInsets.symmetric(horizontal: 10), //height: 60, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5), ), child: TextFormField( controller: _km[i], autofocus: false, style: const TextStyle(color: Colors.black), decoration: const InputDecoration( border: InputBorder.none, hintText: "KM", hintStyle: TextStyle( color: Color.fromARGB(255, 132, 140, 155)), ), ), ), ), /* i != 0 ? GestureDetector( onTap: (){ setState(() { _removeItemTempat(i); }); }, child: const Icon( Icons.delete, color: Color(0xFF6B74D6), size: 40, ), ) : const SizedBox()*/ ], ), ); }, ), const SizedBox( height: 10, ), /*GestureDetector( onTap: () { setState(() { _addFieldTempat(); }); }, child: Center( child: Container( width: size.width, padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), decoration: BoxDecoration( color: Colors.blueAccent, borderRadius: BorderRadius.circular(5)), child: Align( alignment: Alignment.center, child: Text("Tambah Data Tempat+", style: GoogleFonts.nunito(color: const Color(0xFFF8F8FF))), ), ), ), ),*/ ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Catatan', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), Container( width: size.width, decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white), padding: EdgeInsets.all(10), child: Align( alignment: Alignment.centerLeft, child: Text( catatan, style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Foto', style: GoogleFonts.inconsolata( fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ListView.builder( shrinkWrap: true, itemCount: _ambilFoto.length, itemBuilder: (context, i) { return Padding( padding: const EdgeInsets.only(top: 2), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Column( children:[ Visibility ( child: Align( alignment: Alignment.centerLeft, child: InkWell( child: Container( padding: EdgeInsets.all(5), //width: size.width * 0.5, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), gradient: LinearGradient( colors: [ Colors.redAccent, Colors.redAccent ], ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Ambil Foto\t\t", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, //fontSize: 17, fontWeight: FontWeight.w500, ), ), const Icon( Icons.camera_alt, //color: Color(0xFF6B74D6), size: 25, ), ], ), ), onTap: () async { final ImagePicker _picker = ImagePicker(); final XFile? imagePicked = await _picker.pickImage( source: ImageSource.camera); if (imagePicked != null) { _imagePath = File(imagePicked.path); logDev.log(_imagePath.toString(), name: "IMAGE PATH"); List imageBytes = _imagePath!.readAsBytesSync(); String base64Image = base64Encode(imageBytes); //logDev.log(base64Image, name: "String base64"); setState(() { logDev.log(_ambilFoto.length.toString(), name: "ada berapa banyak buttonambil foto"); _pathFoto[i] = path.basename(_imagePath.toString()); _base64Foto[i] = base64Image; logDev.log(_pathFoto.length.toString(), name: "Banyak path foto"); logDev.log(_base64Foto.length.toString(), name: "Banyak Base64"); logDev.log(_pathFoto.toString(), name: "Isi Path FOTO"); }); } else if (imagePicked == null) { //_imagePath = await getImageFileFromAssets('assets/images/ic_administrator.png') as File?; } }, ), ), ), Visibility( child: Align( alignment: Alignment.centerLeft, child: FittedBox( fit: BoxFit.scaleDown, // Sesuaikan teks agar tidak melebihi lebar container child: Text( _pathFoto[i] /*style: TextStyle(fontSize: size.width),*/ ), ), ) ), ] ) ), /*GestureDetector( onTap: () { setState(() { _removeItemFoto(i); logDev.log(_pathFoto.length.toString(), name: "Banyak path foto"); logDev.log(_pathFoto.toString(), name: "Isi Path FOTO"); }); }, child: const Icon( Icons.delete, color: Color(0xFF6B74D6), size: 40, ) )*/ ], ), ); }, ), const SizedBox( height: 5, ), /*GestureDetector( onTap: () { setState(() { _addFieldFoto(); }); }, child: Center( child: Container( width: MediaQuery.of(context).size.width, padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), decoration: BoxDecoration( color: Colors.blueAccent, borderRadius: BorderRadius.circular(5), ), child: Align( alignment: Alignment.center, child: Text( "Tambah Foto+", style: GoogleFonts.nunito( color: const Color(0xFFF8F8FF), ), ), ), ), ), ),*/ ], ), ), ], ), ), ), ), ], ), ), ), ], ), ], )), ); } //Validasi Form Survey bool validateFormSurvey(BuildContext context) { bool result = true; if (nama_desa == "" && visibleFormDesa == false) { Fluttertoast.showToast( msg: "Nama Desa Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (visibleFormDesa == true){ Fluttertoast.showToast( msg: "Mohon Konfirmasi Data Desa Terlebih Dahulu!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (nama_kecamatan == "" && visibleFormKecamatan == false) { Fluttertoast.showToast( msg: "Nama Kecamatan Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (visibleFormKecamatan == true){ Fluttertoast.showToast( msg: "Mohon Konfirmasi Data Kecamatan Terlebih Dahulu!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (nama_kabupaten == "" && visibleFormKabupaten == false) { Fluttertoast.showToast( msg: "Nama Kabupaten Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (visibleFormKabupaten == true){ Fluttertoast.showToast( msg: "Mohon Konfirmasi Data Kabupaten Terlebih Dahulu!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (nama_provinsi == "" && visibleFormProvinsi == false) { Fluttertoast.showToast( msg: "Nama Provinsi Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (visibleFormProvinsi == true){ Fluttertoast.showToast( msg: "Mohon Konfirmasi Data Provinsi Terlebih Dahulu!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (isiJumlahPendudukTeksController.text.toString().isEmpty) { Fluttertoast.showToast( msg: "Jumlah Penduduk Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (isiSignal2TeksController.text.toString().isEmpty) { Fluttertoast.showToast( msg: "Signal 2G Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (isiSignal3TeksController.text.toString().isEmpty) { Fluttertoast.showToast( msg: "Signal 3G Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (isiSignal4TeksController.text.toString().isEmpty) { Fluttertoast.showToast( msg: "Signal 4G Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (_jenisTempat[0].text.toString().isEmpty){ Fluttertoast.showToast( msg: "Tempat Keramaian Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (_km[0].text.toString().isEmpty){ Fluttertoast.showToast( msg: "Tempat Keramaian Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } else if (isiCatatanTeksController.text.toString().isEmpty) { Fluttertoast.showToast( msg: "Catatan Harus Diisi!", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1, textColor: Colors.white, fontSize: 16.0); result = false; } return result; } } alertDialogFailedRetrievedData(BuildContext context){ Widget okButton = TextButton( child: Text("Refresh"), onPressed: () { Navigator.of(context, rootNavigator: true).pop(); Navigator.pushReplacement(context, MaterialPageRoute( builder: (context) => DetailSurveyScreen())); }, ); Widget noButton = TextButton( child: Text("Back"), onPressed: () { Navigator.of(context, rootNavigator: true).pop(); Navigator.pop(context); }, ); // set up the AlertDialog AlertDialog alert = AlertDialog( title: Text("Tower Application"), content: Text("Failed to Retrieve Data"), actions: [ noButton, okButton, ], ); // show the dialog showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return alert; }, ); } alertDialogFailedResponse(BuildContext context){ Widget okButton = TextButton( child: Text("Refresh"), onPressed: () { Navigator.of(context, rootNavigator: true).pop(); Navigator.pushReplacement(context, MaterialPageRoute( builder: (context) => DetailSurveyScreen())); }, ); Widget noButton = TextButton( child: Text("Back"), onPressed: () { Navigator.of(context, rootNavigator: true).pop(); Navigator.pop(context); }, ); // set up the AlertDialog AlertDialog alert = AlertDialog( title: Text("Tower Application"), content: Text("Server Response Error"), actions: [ noButton, okButton, ], ); // show the dialog showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return alert; }, ); }