From df4b2053e79c71704b02fd72dcfe52bfd28d6888 Mon Sep 17 00:00:00 2001 From: josxha <34318751+josxha@users.noreply.github.com> Date: Fri, 21 Jul 2023 01:25:11 +0200 Subject: [PATCH] use math min() / max() --- lib/src/misc/private/bounds.dart | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/src/misc/private/bounds.dart b/lib/src/misc/private/bounds.dart index 9a7fcebc1..e5fec1eac 100644 --- a/lib/src/misc/private/bounds.dart +++ b/lib/src/misc/private/bounds.dart @@ -25,26 +25,13 @@ class Bounds { var minY = double.infinity; for (final point in points) { - if (point.x > maxX) { - maxX = point.x; - } - if (point.x < minX) { - minX = point.x; - } - if (point.y > maxY) { - maxY = point.y; - } - if (point.y < minY) { - minY = point.y; - } + maxX = math.max(point.x, maxX); + minX = math.min(point.x, minX); + maxY = math.max(point.y, maxY); + minY = math.min(point.y, minY); } - final bounds = Bounds._( - Point(minX, minY), - Point(maxX, maxY), - ); - - return bounds; + return Bounds._(Point(minX, minY), Point(maxX, maxY)); } /// Creates a new [Bounds] obtained by expanding the current ones with a new