Skip to content

Commit 5337339

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
🔧 Use dart records for some helper functions.
1 parent 7520da0 commit 5337339

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

packages/box_transform/lib/src/helpers.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ Vector2? intersectionBetweenTwoLines(
234234

235235
/// Extends given line to the given rectangle such that it touches the
236236
/// rectangle.
237-
List<Vector2>? extendLineToRect(Box rect, Vector2 p1, Vector2 p2) {
238-
final result = extendLinePointsToRectPoints(
237+
(Vector2, Vector2)? extendLineToRect(Box rect, Vector2 p1, Vector2 p2) {
238+
final (double, double, double, double)? result = extendLinePointsToRectPoints(
239239
rect.left, rect.top, rect.right, rect.bottom, p1.x, p1.y, p2.x, p2.y);
240240

241241
if (result == null) return null;
242242

243-
return [Vector2(result[0], result[1]), Vector2(result[2], result[3])];
243+
return (Vector2(result.$1, result.$2), Vector2(result.$3, result.$4));
244244
}
245245

246246
/// Extends given line to the given rectangle such that it touches the
247247
/// rectangle points.
248-
List<double>? extendLinePointsToRectPoints(
248+
(double, double, double, double)? extendLinePointsToRectPoints(
249249
double left,
250250
double top,
251251
double right,
@@ -256,10 +256,10 @@ List<double>? extendLinePointsToRectPoints(
256256
double y2,
257257
) {
258258
if (y1 == y2) {
259-
return [left, y1, right, y1];
259+
return (left, y1, right, y1);
260260
}
261261
if (x1 == x2) {
262-
return [x1, top, x1, bottom];
262+
return (x1, top, x1, bottom);
263263
}
264264

265265
double yForLeft = y1 + (y2 - y1) * (left - x1) / (x2 - x1);
@@ -272,25 +272,25 @@ List<double>? extendLinePointsToRectPoints(
272272
yForLeft <= bottom &&
273273
top <= yForRight &&
274274
yForRight <= bottom) {
275-
return [left, yForLeft, right, yForRight];
275+
return (left, yForLeft, right, yForRight);
276276
} else if (top <= yForLeft && yForLeft <= bottom) {
277277
if (left <= xForBottom && xForBottom <= right) {
278-
return [left, yForLeft, xForBottom, bottom];
278+
return (left, yForLeft, xForBottom, bottom);
279279
} else if (left <= xForTop && xForTop <= right) {
280-
return [left, yForLeft, xForTop, top];
280+
return (left, yForLeft, xForTop, top);
281281
}
282282
} else if (top <= yForRight && yForRight <= bottom) {
283283
if (left <= xForTop && xForTop <= right) {
284-
return [xForTop, top, right, yForRight];
284+
return (xForTop, top, right, yForRight);
285285
}
286286
if (left <= xForBottom && xForBottom <= right) {
287-
return [xForBottom, bottom, right, yForRight];
287+
return (xForBottom, bottom, right, yForRight);
288288
}
289289
} else if (left <= xForTop &&
290290
xForTop <= right &&
291291
left <= xForBottom &&
292292
xForBottom <= right) {
293-
return [xForTop, top, xForBottom, bottom];
293+
return (xForTop, top, xForBottom, bottom);
294294
}
295295
return null;
296296
}
@@ -311,17 +311,17 @@ HandlePosition intersectionBetweenRects({
311311
extendLineToRect(outerRect, innerRect.center, innerRect.topRight)!;
312312

313313
final intersections1 = findLineIntersection(
314-
line1[0],
315-
line1[1],
314+
line1.$1,
315+
line1.$2,
316316
outerRect,
317317
innerRect,
318318
);
319319

320320
intersections1.remove(excludeHandle);
321321

322322
final intersections2 = findLineIntersection(
323-
line2[0],
324-
line2[1],
323+
line2.$1,
324+
line2.$2,
325325
outerRect,
326326
innerRect,
327327
);

0 commit comments

Comments
 (0)