颤动日期时间选择器以添加开始和结æŸæ—¥æœŸ

时间:2019-02-24 07:00:25

标签: dart flutter

我在flutter文档中读到了有关日期时间选择器的信æ¯ï¼Œä½†å®ƒä»…支æŒé€‰æ‹©ä¸€å¤©å¹¶æ˜¾ç¤ºå®ƒ 但是我想è¦é€‰æ‹©ä¸€ä¸ªå¼€å§‹æ—¥æœŸå’Œä¸€ä¸ªç»“æŸæ—¥æœŸä»¥æ˜¾ç¤ºè¿™äº›æ—¥æœŸä¹‹é—´çš„结果

有人å¯ä»¥å¸®åŠ©æˆ‘该怎么åšå—?

1 个答案:

答案 0 :(得分: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(2020)
      );
      if (picked != null && picked.length == 2) {
          print(picked);
      }
    },
    child: new Text("Pick date range")
)

enter image description here

Ref:date_range_picker 1.0.5