Advertisement
Sebuahhobi98

samevalue

Jul 22nd, 2022 (edited)
1,610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.36 KB | None | 0 0
  1. Future<Widget> select2() async {
  2.     final String currentTimeZone =
  3.         await FlutterNativeTimezone.getLocalTimezone();
  4.     timeZoneName = currentTimeZone;
  5.     tz.initializeTimeZones();
  6.     final location = tz.getLocation(currentTimeZone.toString());
  7.  
  8.     DateTime date = tz.TZDateTime.from(DateTime.now(), location);
  9.  
  10.     Coordinates coordinates =
  11.         Coordinates(lat..., long...);
  12.  
  13.     CalculationParameters params = CalculationMethod.Singapore();
  14.     params.madhab = Madhab.Shafi;
  15.  
  16.     PrayerTimes prayerTimes =
  17.         PrayerTimes(coordinates, date, params, precision: true);
  18.  
  19.     DateTime fajrTime = tz.TZDateTime.from(prayerTimes.fajr!, location);
  20.     DateTime sunriseTime = tz.TZDateTime.from(prayerTimes.sunrise!, location);
  21.     DateTime dhuhrTime = tz.TZDateTime.from(prayerTimes.dhuhr!, location);
  22.     DateTime asrTime = tz.TZDateTime.from(prayerTimes.asr!, location);
  23.     DateTime maghribTime = tz.TZDateTime.from(prayerTimes.maghrib!, location);
  24.     DateTime ishaTime = tz.TZDateTime.from(prayerTimes.isha!, location);
  25.  
  26.     SunnahTimes sunnahTimes = SunnahTimes(prayerTimes);
  27.     var qiblaDirection = Qibla.qibla(coordinates);
  28.  
  29.     DateTime dhuha = sunriseTime.add(const Duration(minutes: 20));
  30.     log(dhuha.toString());
  31.     return Padding(
  32.       padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
  33.       child: DropdownButtonFormField2(
  34.         decoration: InputDecoration(
  35.           isDense: true,
  36.           contentPadding: EdgeInsets.zero,
  37.           border: OutlineInputBorder(
  38.             borderRadius: BorderRadius.circular(10),
  39.           ),
  40.         ),
  41.         isExpanded: true,
  42.         hint: const Text(
  43.           'Pilih waktu shalat',
  44.           style: TextStyle(fontSize: 14),
  45.         ),
  46.         icon: const Icon(
  47.           Icons.arrow_drop_down,
  48.           color: Colors.black45,
  49.         ),
  50.         iconSize: 30,
  51.         buttonHeight: 60,
  52.         buttonPadding: const EdgeInsets.only(left: 20, right: 10),
  53.         dropdownDecoration: BoxDecoration(
  54.           borderRadius: BorderRadius.circular(15),
  55.         ),
  56.         items: [
  57.           DropdownMenuItem(
  58.               value: fajrTime,
  59.               child: Text("Subuh: ${DateFormat('HH:mm').format(fajrTime)}")),
  60.           DropdownMenuItem(
  61.               value: sunriseTime,
  62.               child:
  63.                   Text("Terbit: ${DateFormat('HH:mm').format(sunriseTime)}")),
  64.           DropdownMenuItem(
  65.               value: dhuha,
  66.               child: Text("Dhuha: ${DateFormat('HH:mm').format(dhuha)}")),
  67.           DropdownMenuItem(
  68.               value: dhuhrTime,
  69.               child: Text("Dhuhur: ${DateFormat('HH:mm').format(dhuhrTime)}")),
  70.           DropdownMenuItem(
  71.               value: asrTime,
  72.               child: Text("Ashar: ${DateFormat('HH:mm').format(asrTime)}")),
  73.           DropdownMenuItem(
  74.               value: maghribTime,
  75.               child:
  76.                   Text("Maghrib: ${DateFormat('HH:mm').format(maghribTime)}")),
  77.           DropdownMenuItem(
  78.               value: ishaTime,
  79.               child: Text("Isya: ${DateFormat('HH:mm').format(ishaTime)}")),
  80.         ],
  81.         onChanged: (value) {
  82.           selectedWaktuShalat = DateTime.parse(value.toString()).toLocal();
  83.         },
  84.         onSaved: (value) {
  85.           selectedWaktuShalat = DateTime.parse(value.toString()).toLocal();
  86.         },
  87.         value: selectedWaktuShalat,
  88.       ),
  89.     );
  90.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement