我在flutter docs中阅读了日期时间选择器,但它仅支持选择一天并显示它,但我想要的是选择开始日期和结束日期以显示这些日期之间的结果
任何人都可以帮助我如何做到这一点?
您可以使用date_range_picker.
安装它:
date_range_picker: ^1.0.3
Run Code Online (Sandbox Code Playgroud)
并像这样使用:
import 'package:date_range_picker/date_range_picker.dart' as DateRagePicker;
...
new MaterialButton(
color: Colors.deepOrangeAccent,
onPressed: () async {
final List<DateTime> picked = await DateRagePicker.showDatePicker(
context: context,
initialFirstDate: new DateTime.now(),
initialLastDate: (new DateTime.now()).add(new Duration(days: 7)),
firstDate: new DateTime(2015),
lastDate: new DateTime(2030)
);
if (picked != null && picked.length == 2) {
print(picked);
}
},
child: new Text("Pick date range")
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6363 次 |
| 最近记录: |