我在flutter文档ä¸è¯»åˆ°äº†æœ‰å…³æ—¥æœŸæ—¶é—´é€‰æ‹©å™¨çš„ä¿¡æ¯ï¼Œä½†å®ƒä»…支æŒé€‰æ‹©ä¸€å¤©å¹¶æ˜¾ç¤ºå®ƒ 但是我想è¦é€‰æ‹©ä¸€ä¸ªå¼€å§‹æ—¥æœŸå’Œä¸€ä¸ªç»“æŸæ—¥æœŸä»¥æ˜¾ç¤ºè¿™äº›æ—¥æœŸä¹‹é—´çš„结果
有人å¯ä»¥å¸®åŠ©æˆ‘该怎么åšå—?
ç”案 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")
)
Ref:date_range_picker 1.0.5