Skip to content

Commit

Permalink
bugs fixed (#65)
Browse files Browse the repository at this point in the history
Fix: Automatic refresh issue when the second date was smaller than the first date.
Fix: Inability to decrease the second date even if the first date was smaller.
  • Loading branch information
ahmtydn committed May 27, 2023
1 parent 09af953 commit 60c774c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/widgets/range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class RangePicker extends StatefulWidget {
}

class _RangePickerState extends State<RangePicker> {
late DateTime initialSecondDate = widget.minSecondDate ?? DateTime.now();
late DateTime initialSecondDate =
widget.initialSecondDateTime ?? DateTime.now();
late DateTime minSecondDate = widget.initialSecondDateTime ?? DateTime.now();

@override
Widget build(BuildContext context) {
Expand All @@ -50,6 +52,11 @@ class _RangePickerState extends State<RangePicker> {
widget.onSecondDateChanged.call(date);
setState(() {
initialSecondDate = date;
minSecondDate = date;
});
} else {
setState(() {
minSecondDate = date;
});
}
},
Expand All @@ -59,9 +66,10 @@ class _RangePickerState extends State<RangePicker> {
),
Expanded(
child: DatePicker(
key: UniqueKey(),
initialDateTime: initialSecondDate,
maxDateTime: widget.maxSecondDate,
minDateTime: initialSecondDate,
minDateTime: minSecondDate,
mode: CupertinoDatePickerMode.date,
onDateChanged: widget.onSecondDateChanged,
dateOrder: widget.dateOrder,
Expand Down

0 comments on commit 60c774c

Please sign in to comment.