File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ extension DurationTimeExtension on Duration {
301
301
/// ```
302
302
Duration clamp ({Duration ? min, Duration ? max}) {
303
303
assert (
304
- ((min != null ) && (max != null )) ? min.compareTo (max).isNegative : true ,
304
+ ((min != null ) && (max != null )) ? min.compareTo (max) <= 0 : true ,
305
305
'Duration min has to be shorter than max\n (min: $min - max: $max )' ,
306
306
);
307
307
if ((min != null ) && compareTo (min).isNegative) {
Original file line number Diff line number Diff line change @@ -744,6 +744,13 @@ void main() {
744
744
throwsA (isA <AssertionError >()),
745
745
);
746
746
});
747
+
748
+ test ('returns min/max if are equal' , () {
749
+ final it = Duration (days: - 0 );
750
+ final min = Duration (days: 5 );
751
+ final max = min;
752
+ expect (it.clamp (min: min, max: max), min);
753
+ });
747
754
});
748
755
});
749
756
}
You can’t perform that action at this time.
0 commit comments