日期范围选择器?
日期范围选择器是一个用户友好且简单的 Flutter 包,允许用户选择日期范围。它旨在随着时间的推移而发展,其组件具有可重用性。
(它不美观吗?)
特性 ✅
- 简单易用的界面
- 可定制主题
- 可重用组件
- 支持最小和最大日期限制
- 一次显示两个月,方便导航
安装?
将包添加到您的 pubspec.yaml 文件
dependencies:
date_range_picker: ^latest
然后在终端运行 flutter packages get。
用法 ?
要使用日期范围选择器,只需导入该包并创建一个 DateRangePickerWidget
import 'package:flutter_date_range_picker/date_range_picker.dart';
DateRangePickerWidget
(
onPeriodChanged: (period) {
// Handle the selected period here
},
);
自定义?
您可以通过提供自定义 CalendarTheme 来自定义日期范围选择器的外观
DateRangePickerWidget
(
onPeriodChanged: (period) {
// Handle the selected period here
},
theme: CalendarTheme(
selectedColor: Colors.blue,
dayNameTextStyle: TextStyle(color: Colors.black45, fontSize: 10),
inRangeColor: Color(0xFFD9EDFA),
inRangeTextStyle: TextStyle(color: Colors.blue),
selectedTextStyle: TextStyle(color: Colors.white),
todayTextStyle: TextStyle(color: Colors.red),
defaultTextStyle: TextStyle(color: Colors.black, fontSize: 12),
radius: 10,
tileSize: 40,
),
);
您还可以指定初始显示日期、最小日期、最大日期和初始选定期间
DateRangePickerWidget
(
onPeriodChanged: (period) {
// Handle the selected period here
},
initialDisplayedDate: DateTime.now(),
initialPeriod: Period(start: DateTime.now(), end: DateTime.now().add(Duration(days: 7))),
minDate: DateTime.now().subtract(Duration(days: 30)),
maxDate: DateTime.now().add(Duration(days
:
30
)
)
,
);
许可?
此包根据 MIT 许可证发布。
贡献?
我们鼓励并欢迎社区的贡献,以帮助改进和发展此项目。如果您想做出贡献,请随时 Fork 仓库、进行更改并提交拉取请求。
贡献时,请牢记以下准则
- 始终遵循 Flutter 和 Dart 的最佳实践和编码标准。
- 编写清晰、简洁且文档齐全的代码。
- 在提交拉取请求之前,彻底测试您的更改。
- 添加或更新与您的更改相关的任何必要文档。
- 尊重现有代码库并保持其结构和风格。
如果您有任何问题或需要指导,请随时联系此项目的维护者。我们感谢您的兴趣和支持,并期待与您合作!
