coerceIn method

DateTime coerceIn({
  1. DateTime? min,
  2. DateTime? max,
})

Implementation

DateTime coerceIn({DateTime? min, DateTime? max}) {
  DateTime temp = add(Duration.zero);
  if (min == null && max == null) {
    return temp;
  } else {
    if (min != null && max != null) {
      assert(!min.isAfter(max));
    }
    if (min != null && temp.isBefore(min)) {
      temp = min;
    }
    if (max != null && temp.isAfter(max)) {
      temp = max;
    }
  }
  return temp;
}