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 {
301301 /// ```
302302 Duration clamp({Duration? min, Duration? max}) {
303303 assert(
304- ((min != null) && (max != null)) ? min.compareTo(max).isNegative : true,
304+ ((min != null) && (max != null)) ? min.compareTo(max) <= 0 : true,
305305 'Duration min has to be shorter than max\n(min: $min - max: $max)',
306306 );
307307 if ((min != null) && compareTo(min).isNegative) {
Original file line number Diff line number Diff line change @@ -752,6 +752,13 @@ void main() {
752752 throwsA(isA<AssertionError>()),
753753 );
754754 });
755+
756+ test('returns min/max if are equal', () {
757+ final it = Duration(days: -0);
758+ final min = Duration(days: 5);
759+ final max = min;
760+ expect(it.clamp(min: min, max: max), min);
761+ });
755762 });
756763 });
757764}
You can’t perform that action at this time.
0 commit comments