英文:
How to limit the time in showDatePicker or showDateRangePicker Flutter
问题
I need to set Date limit at DatePicker. like i need to set date picker in between 12 Mar, 2023 to 20 Mar, 2023 and another date i don't want to select from user. user can select date in between 12 Mar, 2023 to 20 Mar, 2023 from date picker so how can we set that.
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2023, 3, 12),
lastDate: DateTime(2023, 3, 20),
);
I want to set limit at DatePicker based on requirement. Is there any way to set it. like any Property or any third party package?
英文:
I need to set Date limit at DatePicker. like i need to set date picker in between 12 Mar,2023 to 20 Mar,2023 and another date i don't want to select from user. user can select date in between 12 Mar,20233 to 20 Mar,2023 from date picker so how can we set that.
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(1950),
lastDate: DateTime(2100),
);
I want to set limit at DatePicker based on requirement. Is there any way to set it. like any Property or any third party package?
答案1
得分: 1
你可以轻松地在“日期选择器”中定义“年、月和日”来设置日期范围。
final DateTime pickedDate = await showDatePicker(
context: context,
initialDate: DateTime(2021, 3, 15),
firstDate: DateTime(2021, 3, 12),
lastDate: DateTime(2023, 3, 20),
);
英文:
You can easily set Date
range in Date Picker
defining year, month & day.
final DateTime pickedDate = await showDatePicker(
context: context,
initialDate: DateTime(2021, 3, 15),
firstDate: DateTime(2021, 3, 12),
lastDate: DateTime(2023, 3, 20),
);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论