@@ -16,6 +16,9 @@ part of dart.math;
16
16
/// The rectangle is the set of points with representable coordinates greater
17
17
/// than or equal to left/top, and with distance to left/top no greater than
18
18
/// width/height (to the limit of the precision of the coordinates).
19
+ ///
20
+ /// **Legacy:** New usages of [_RectangleBase] are discouraged.
21
+ /// To learn more, check out the [Rectangle] class API docs.
19
22
abstract class _RectangleBase <T extends num > {
20
23
const _RectangleBase ();
21
24
@@ -117,6 +120,27 @@ abstract class _RectangleBase<T extends num> {
117
120
118
121
/// A class for representing two-dimensional rectangles whose properties are
119
122
/// immutable.
123
+ ///
124
+ /// **Legacy:** New usages of [Rectangle] are discouraged.
125
+ ///
126
+ /// - If you are using the `Rectangle` class with `dart:html` ,
127
+ /// we recommend migrating to `package:web` .
128
+ /// To learn how and why to migrate,
129
+ /// check out the [migration guide] (https://dart.dev/go/package-web).
130
+ /// - If you want to store the boundaries of a rectangle
131
+ /// in some coordinate system,
132
+ /// consider using a [record] (https://dart.dev/language/records).
133
+ /// Depending on how you will use it, this could look
134
+ /// like `var boundaries = (mixX: x1, maxX: x2, minY: y1, maxY: y2)` .
135
+ /// - If you need to perform intersection calculations or containment checks,
136
+ /// consider using a dedicated library, such as
137
+ /// [`package:vector_math`] (https://pub.dev/packages/vector_math).
138
+ /// - If you are developing a Flutter application or package,
139
+ /// consider using the
140
+ /// [`Rect`] (https://api.flutter.dev/flutter/dart-ui/Rect-class.html)
141
+ /// type from `dart:ui` .
142
+ // TODO: @Deprecated(
143
+ // 'Use records or a dedicated library like package:vector_math instead.')
120
144
class Rectangle <T extends num > extends _RectangleBase <T > {
121
145
final T left;
122
146
final T top;
@@ -144,6 +168,9 @@ class Rectangle<T extends num> extends _RectangleBase<T> {
144
168
/// print(rectangle.right); // 320
145
169
/// print(rectangle.bottom); // 650
146
170
/// ```
171
+ ///
172
+ /// **Legacy:** New usages of [Rectangle] are discouraged.
173
+ /// To learn more, check out the [Rectangle] class API docs.
147
174
const Rectangle (this .left, this .top, T width, T height)
148
175
: width = (width < 0 )
149
176
? (width == double .negativeInfinity ? 0.0 : (- width * 0 )) as dynamic
@@ -187,6 +214,27 @@ class Rectangle<T extends num> extends _RectangleBase<T> {
187
214
188
215
/// A class for representing two-dimensional axis-aligned rectangles with
189
216
/// mutable properties.
217
+ ///
218
+ /// **Legacy:** New usages of [MutableRectangle] are discouraged.
219
+ ///
220
+ /// - If you are using the `MutableRectangle` class with `dart:html` ,
221
+ /// we recommend migrating to `package:web` .
222
+ /// To learn how and why to migrate,
223
+ /// check out the [migration guide] (https://dart.dev/go/package-web).
224
+ /// - If you want to store the boundaries of a rectangle
225
+ /// in some coordinate system,
226
+ /// consider using a [record] (https://dart.dev/language/records).
227
+ /// Depending on how you will use it, this could look
228
+ /// like `var boundaries = (mixX: x1, maxX: x2, minY: y1, maxY: y2)` .
229
+ /// - If you need to perform intersection calculations or containment checks,
230
+ /// consider using a dedicated library, such as
231
+ /// [`package:vector_math`] (https://pub.dev/packages/vector_math).
232
+ /// - If you are developing a Flutter application or package,
233
+ /// consider using the
234
+ /// [`Rect`] (https://api.flutter.dev/flutter/dart-ui/Rect-class.html)
235
+ /// type from `dart:ui` .
236
+ // TODO: @Deprecated(
237
+ // 'Use records or a dedicated library like package:vector_math instead.')
190
238
class MutableRectangle <T extends num > extends _RectangleBase <T >
191
239
implements Rectangle <T > {
192
240
/// The x-coordinate of the left edge.
@@ -233,6 +281,9 @@ class MutableRectangle<T extends num> extends _RectangleBase<T>
233
281
/// print(rectangle.right); // 220
234
282
/// print(rectangle.bottom); // 150
235
283
/// ```
284
+ ///
285
+ /// **Legacy:** New usages of [MutableRectangle] are discouraged.
286
+ /// To learn more, check out the [MutableRectangle] class API docs.
236
287
MutableRectangle (this .left, this .top, T width, T height)
237
288
: this ._width =
238
289
(width < 0 ) ? _clampToZero <T >(width) : (width + 0 as dynamic ),
0 commit comments