【问题标题】:flutter date time picker to add start and end dates颤动日期时间选择器以添加开始和结束日期
【发布时间】:2019-07-17 20:57:32
【问题描述】:

我在颤振文档中阅读了日期时间选择器,但它只支持选择一天并显示它 但我想要的是选择开始日期和结束日期以显示这些日期之间的结果

任何人都可以帮助我如何做到这一点?

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    您可以使用date_range_picker

    安装它:

      date_range_picker: ^1.0.3
    

    并像这样使用:

    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")
    )
    

    参考:date_range_picker 1.0.5

    【讨论】:

    • 为什么我不能通过点击年份来选择日期?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 2016-08-21
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多