From e866a2b12ce0cd6205818de0e47ec2b5578a03db Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 21 Dec 2020 10:14:24 +0800 Subject: [PATCH] update 2datePicker --- lib/pickers/as_date_range_picker_part.dart | 5 +++-- lib/pickers/as_two_date_picker.dart | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pickers/as_date_range_picker_part.dart b/lib/pickers/as_date_range_picker_part.dart index c36bbc7..678a3e3 100644 --- a/lib/pickers/as_date_range_picker_part.dart +++ b/lib/pickers/as_date_range_picker_part.dart @@ -12,11 +12,12 @@ class RangeDate { ///返回值为`bool`且为`true`时,为一小时内 /// ///否则返回`RangeDate` -Future show2DatePicker(BuildContext context) async { +Future show2DatePicker(BuildContext context, + {bool isAnHour, RangeDate date}) async { return await showModalBottomSheet( context: context, builder: (context) { - return AS2DatePicker(); + return AS2DatePicker(isAnHour:isAnHour,date:date); }, ); } diff --git a/lib/pickers/as_two_date_picker.dart b/lib/pickers/as_two_date_picker.dart index 6b728d9..a70a7ea 100644 --- a/lib/pickers/as_two_date_picker.dart +++ b/lib/pickers/as_two_date_picker.dart @@ -1,7 +1,9 @@ part of ansu_ui; class AS2DatePicker extends StatefulWidget { - AS2DatePicker({Key key}) : super(key: key); + final bool isAnHour; + final RangeDate date; + AS2DatePicker({Key key, this.isAnHour, this.date}) : super(key: key); @override _AS2DatePickerState createState() => _AS2DatePickerState(); @@ -152,6 +154,8 @@ class _AS2DatePickerState extends State { super.initState(); _pageController = PageController(); _selectedDate = now; + _inAnHour = widget.isAnHour ?? true; + _selectedDate = widget.date?.start ?? now; } @override