class DateTimeMaxMin {
static const _numDays = 100000000;
static DateTime get min => DateTime.fromMicrosecondsSinceEpoch(0).subtract(Duration(days: _numDays));
static DateTime get max => DateTime.fromMicrosecondsSinceEpoch(0).add(Duration(days: _numDays));
}
// DateTimes can represent time values that are at a distance of at most 100,000,000
// days from epoch (1970-01-01 UTC): -271821-04-20 to 275760-09-13.
static DateTime minDateTime = DateTime.utc(-271821,04,20);
static DateTime maxDateTime = DateTime.utc(275760,09,13);
3条答案
按热度按时间ia2d9nvy1#
这似乎不是目前可用的东西。您可以提出一个特性请求,然后看看会发生什么,但现在唯一要做的就是为最大值和最小值创建getter。不幸的是,我们也不能创建静态扩展方法,所以你只能使用静态类或全局变量:
字符串
41zrol4v2#
我在这篇文章中看到有人定义了min/max:
https://github.com/google/json_serializable.dart/issues/796
字符串
flvlnr443#
对于
showDateRangePicker
中的firstDate
,minDateTime类似于DateTime.utc(-271820, 12, 31)