import 'package:fikoyt_merkez/core/fikoyt.service.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; import 'package:intl/date_symbol_data_local.dart'; extension FikoTarih on DateTime { String? string(String pattern) { try { return DateFormat(pattern).format(this); } catch (e) { return null; } } String formatla(String format) { initializeDateFormatting(); DateFormat dateFormat = DateFormat(format, "tr_tr"); return dateFormat.format(this); } DateTime formattan(String format, String tarih) { DateFormat dateFormat = DateFormat(format); return dateFormat.parse(tarih); } String farkToString(DateTime? tarih) { tarih = tarih ?? DateTime.now(); return toIso8601String(); } TimeOfDay gununSaati() { TimeOfDay time = TimeOfDay(hour: hour, minute: minute); return time; } DateTime ayarlaGununSaati(TimeOfDay saat) { TimeOfDay time = TimeOfDay(hour: saat.hour, minute: saat.minute); DateTime currentDateTime = DateTime(year, month, day, time.hour, time.minute); return currentDateTime; } Future saatSec(BuildContext context, {TimeOfDay? gecerliSaat}) async { gecerliSaat ??= TimeOfDay(hour: hour, minute: minute); TimeOfDay? value = await showTimePicker(context: context, initialTime: gecerliSaat); if (value == null) return null; DateTime rslt = DateTime(year, month, day, value.hour, value.minute, 0, 0, 0); return rslt; } Future tarihSec(BuildContext context, {DateTime? gecerliTarihSaat, DateTime? varsayilanTarihSaat}) async { gecerliTarihSaat ??= DateTime( year, month, day, hour, minute, second, millisecond, microsecond); DateTime? value = await showDatePicker( context: context, firstDate: DateTime.fromMillisecondsSinceEpoch(0), lastDate: DateTime.now(), initialDate: gecerliTarihSaat); if (value == null) return varsayilanTarihSaat; DateTime rslt = DateTime(value.year, value.month, value.day, hour, minute, second, millisecond, microsecond); return rslt; } Future tarihSaatSec(BuildContext context, {DateTime? gecerliTarihSaat, DateTime? varsayilanTarihSaat}) async { gecerliTarihSaat ??= DateTime( year, month, day, hour, minute, second, millisecond, microsecond); DateTime? selectedDate = await FikoYTService.tarihSec( context, varsayilanTarih: varsayilanTarihSaat, ); DateTime? selectedTime = null; // After selecting the date, display the time picker. if (selectedDate != null) { selectedTime = await FikoYTService.saatSec( // ignore: use_build_context_synchronously context, varsayilanTarih: gecerliTarihSaat, ); if (selectedTime == null) return varsayilanTarihSaat; } else { return varsayilanTarihSaat; } return DateTime( selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute, ); } Future tarihSaatSec1(BuildContext context, {DateTime? gecerliTarihSaat, DateTime? varsayilanTarihSaat}) async { gecerliTarihSaat ??= DateTime( year, month, day, hour, minute, second, millisecond, microsecond); DateTime? selectedDate = await showDatePicker( context: context, initialDate: gecerliTarihSaat, firstDate: DateTime(2000), lastDate: DateTime(2500), ); TimeOfDay? selectedTime = null; // After selecting the date, display the time picker. if (selectedDate != null) { selectedTime = await showTimePicker( // ignore: use_build_context_synchronously context: context, initialTime: gecerliTarihSaat.gununSaati(), ); if (selectedTime == null) return varsayilanTarihSaat; } else { return varsayilanTarihSaat; } return DateTime( selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute, ); } }