From af493867bba47272482e80fc281ffa93f4c4afaa Mon Sep 17 00:00:00 2001 From: Kalpesh Patel <1988.kalpesh@gmail.com> Date: Fri, 26 Apr 2024 13:33:00 +0530 Subject: [PATCH] Set initial value in text field in date field. (#67) --- lib/components/datepicker/date_picker.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/components/datepicker/date_picker.dart b/lib/components/datepicker/date_picker.dart index 3db1778..fdee36b 100644 --- a/lib/components/datepicker/date_picker.dart +++ b/lib/components/datepicker/date_picker.dart @@ -78,6 +78,14 @@ class _TUIDatePickerState extends State { super.initState(); _dateController = widget.controller ?? material.TextEditingController(); _dateFormat = widget.format ?? _getDefaultDateTimeFormat(); + if (widget.initialDate != null || widget.initialTime != null) { + if (widget.initialDate != null) { + _selectedDate = combine(widget.initialDate!, widget.initialTime); + } else { + _selectedDate = convert(widget.initialTime); + } + _dateController.text = _dateFormat.format(_selectedDate!); + } } @override