TimeRangePickerModel constructor
TimeRangePickerModel({})
Implementation
TimeRangePickerModel({
DateTime? currentTime,
DateTime? maxTime,
DateTime? minTime,
this.showSeconds = false,
List<String>? formats,
List<bool>? labels,
List<int>? weights,
List<String>? dividers,
}) : assert(weights == null || weights.length == 3),
assert(dividers == null || dividers.length == 2),
assert(labels == null || labels.length == 3),
assert(formats == null || formats.length == 3) {
this.weights = weights ?? [1, 1, showSeconds ? 1 : 0];
this.dividers = dividers ?? [':', showSeconds ? ':' : ''];
this.formats = formats ?? [HH, mm, ss];
this.labels = labels ?? [false, false, false];
this.maxTime = maxTime ??
DateTime(0).add(Duration(hours: 23, minutes: 59, seconds: 59));
this.minTime =
minTime ?? DateTime(0).add(Duration(hours: 0, minutes: 0, seconds: 0));
currentTime = currentTime ?? DateTime.now();
if (timeCompare(currentTime, this.maxTime) > 0) {
currentTime = this.maxTime;
} else if (timeCompare(currentTime, this.minTime) < 0) {
currentTime = this.minTime;
}
this.currentTime = currentTime;
_fillHourList();
_fillMinuteList();
_fillSecondList();
int minMinute = _minMinuteOfCurrentHour();
int minSecond = _minSecondOfCurrentMinute();
firstIndex = this.currentTime.hour - this.minTime.hour;
secondIndex = this.currentTime.minute - minMinute;
thirdIndex = this.currentTime.second - minSecond;
}