diff --git a/engine/src/flutter/lib/ui/geometry.dart b/engine/src/flutter/lib/ui/geometry.dart index 3d6183d62e..a3ac1d9984 100644 --- a/engine/src/flutter/lib/ui/geometry.dart +++ b/engine/src/flutter/lib/ui/geometry.dart @@ -13,14 +13,12 @@ abstract class OffsetBase { /// /// The first argument sets the horizontal component, and the second the /// vertical component. - const OffsetBase(double dx, double dy) - : _dx = dx ?? 0.0, - _dy = dy ?? 0.0, - assert(dx != null), - assert(dy != null); + const OffsetBase(this._dx, this._dy) + : assert(_dx != null), + assert(_dy != null); - final double _dx; - final double _dy; + final double/*!*/ _dx; + final double/*!*/ _dy; /// Returns true if either component is [double.infinity], and false if both /// are finite (or negative infinity, or NaN). @@ -31,7 +29,7 @@ abstract class OffsetBase { /// See also: /// /// * [isFinite], which is true if both components are finite (and not NaN). - bool get isInfinite => _dx >= double.infinity || _dy >= double.infinity; + bool/*!*/ get isInfinite => _dx >= double.infinity || _dy >= double.infinity; /// Whether both components are finite (neither infinite nor NaN). /// @@ -39,7 +37,7 @@ abstract class OffsetBase { /// /// * [isInfinite], which returns true if either component is equal to /// positive infinity. - bool get isFinite => _dx.isFinite && _dy.isFinite; + bool/*!*/ get isFinite => _dx.isFinite && _dy.isFinite; /// Less-than operator. Compares an [Offset] or [Size] to another [Offset] or /// [Size], and returns true if both the horizontal and vertical values of the @@ -48,7 +46,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator <(OffsetBase other) => _dx < other._dx && _dy < other._dy; + bool/*!*/ operator <(OffsetBase/*!*/ other) => _dx < other._dx && _dy < other._dy; /// Less-than-or-equal-to operator. Compares an [Offset] or [Size] to another /// [Offset] or [Size], and returns true if both the horizontal and vertical @@ -58,7 +56,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator <=(OffsetBase other) => _dx <= other._dx && _dy <= other._dy; + bool/*!*/ operator <=(OffsetBase/*!*/ other) => _dx <= other._dx && _dy <= other._dy; /// Greater-than operator. Compares an [Offset] or [Size] to another [Offset] /// or [Size], and returns true if both the horizontal and vertical values of @@ -68,7 +66,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator >(OffsetBase other) => _dx > other._dx && _dy > other._dy; + bool/*!*/ operator >(OffsetBase/*!*/ other) => _dx > other._dx && _dy > other._dy; /// Greater-than-or-equal-to operator. Compares an [Offset] or [Size] to /// another [Offset] or [Size], and returns true if both the horizontal and @@ -78,24 +76,24 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator >=(OffsetBase other) => _dx >= other._dx && _dy >= other._dy; + bool/*!*/ operator >=(OffsetBase/*!*/ other) => _dx >= other._dx && _dy >= other._dy; /// Equality operator. Compares an [Offset] or [Size] to another [Offset] or /// [Size], and returns true if the horizontal and vertical values of the /// left-hand-side operand are equal to the horizontal and vertical values of /// the right-hand-side operand respectively. Returns false otherwise. @override - bool operator ==(dynamic other) { + bool/*!*/ operator ==(dynamic other) { return other is OffsetBase && other._dx == _dx && other._dy == _dy; } @override - int get hashCode => hashValues(_dx, _dy); + int/*!*/ get hashCode => hashValues(_dx, _dy); @override - String toString() => 'OffsetBase(${_dx?.toStringAsFixed(1)}, ${_dy?.toStringAsFixed(1)})'; + String/*!*/ toString() => 'OffsetBase(${_dx.toStringAsFixed(1)}, ${_dy.toStringAsFixed(1)})'; } /// An immutable 2D floating-point offset. @@ -122,37 +120,37 @@ abstract class OffsetBase { class Offset extends OffsetBase { /// Creates an offset. The first argument sets [dx], the horizontal component, /// and the second sets [dy], the vertical component. - const Offset(double dx, double dy) : super(dx, dy); + const Offset(double/*!*/ dx, double/*!*/ dy) : super(dx, dy); /// Creates an offset from its [direction] and [distance]. /// /// The direction is in radians clockwise from the positive x-axis. /// /// The distance can be omitted, to create a unit vector (distance = 1.0). - factory Offset.fromDirection(double direction, [ double distance = 1.0 ]) { + factory Offset.fromDirection(double/*!*/ direction, [ double/*!*/ distance = 1.0 ]) { return Offset(distance * math.cos(direction), distance * math.sin(direction)); } /// The x component of the offset. /// /// The y component is given by [dy]. - double get dx => _dx; + double/*!*/ get dx => _dx; /// The y component of the offset. /// /// The x component is given by [dx]. - double get dy => _dy; + double/*!*/ get dy => _dy; /// The magnitude of the offset. /// /// If you need this value to compare it to another [Offset]'s distance, /// consider using [distanceSquared] instead, since it is cheaper to compute. - double get distance => math.sqrt(dx * dx + dy * dy); + double/*!*/ get distance => math.sqrt(dx * dx + dy * dy); /// The square of the magnitude of the offset. /// /// This is cheaper than computing the [distance] itself. - double get distanceSquared => dx * dx + dy * dy; + double/*!*/ get distanceSquared => dx * dx + dy * dy; /// The angle of this offset as radians clockwise from the positive x-axis, in /// the range -[pi] to [pi], assuming positive values of the x-axis go to the @@ -181,7 +179,7 @@ class Offset extends OffsetBase { /// /// * [distance], to compute the magnitude of the vector. /// * [Canvas.rotate], which uses the same convention for its angle. - double get direction => math.atan2(dy, dx); + double/*!*/ get direction => math.atan2(dy, dx); /// An offset with zero magnitude. /// @@ -215,7 +213,7 @@ class Offset extends OffsetBase { /// Offset a = const Offset(10.0, 10.0); /// Offset b = -a; // same as: a.scale(-1.0, -1.0) /// ``` - Offset scale(double scaleX, double scaleY) => Offset(dx * scaleX, dy * scaleY); + Offset/*!*/ scale(double/*!*/ scaleX, double/*!*/ scaleY) => Offset(dx * scaleX, dy * scaleY); /// Returns a new offset with translateX added to the x component and /// translateY added to the y component. @@ -229,7 +227,7 @@ class Offset extends OffsetBase { /// Offset c = a + b; // same as: a.translate(b.dx, b.dy) /// Offset d = a - b; // same as: a.translate(-b.dx, -b.dy) /// ``` - Offset translate(double translateX, double translateY) => Offset(dx + translateX, dy + translateY); + Offset/*!*/ translate(double/*!*/ translateX, double/*!*/ translateY) => Offset(dx + translateX, dy + translateY); /// Unary negation operator. /// @@ -237,7 +235,7 @@ class Offset extends OffsetBase { /// /// If the [Offset] represents an arrow on a plane, this operator returns the /// same arrow but pointing in the reverse direction. - Offset operator -() => Offset(-dx, -dy); + Offset/*!*/ operator -() => Offset(-dx, -dy); /// Binary subtraction operator. /// @@ -246,7 +244,7 @@ class Offset extends OffsetBase { /// left-hand-side operand's [dy] minus the right-hand-side operand's [dy]. /// /// See also [translate]. - Offset operator -(Offset other) => Offset(dx - other.dx, dy - other.dy); + Offset/*!*/ operator -(Offset/*!*/ other) => Offset(dx - other.dx, dy - other.dy); /// Binary addition operator. /// @@ -255,7 +253,7 @@ class Offset extends OffsetBase { /// two operands. /// /// See also [translate]. - Offset operator +(Offset other) => Offset(dx + other.dx, dy + other.dy); + Offset/*!*/ operator +(Offset/*!*/ other) => Offset(dx + other.dx, dy + other.dy); /// Multiplication operator. /// @@ -264,7 +262,7 @@ class Offset extends OffsetBase { /// right-hand-side operand (a double). /// /// See also [scale]. - Offset operator *(double operand) => Offset(dx * operand, dy * operand); + Offset/*!*/ operator *(double/*!*/ operand) => Offset(dx * operand, dy * operand); /// Division operator. /// @@ -273,21 +271,21 @@ class Offset extends OffsetBase { /// operand (a double). /// /// See also [scale]. - Offset operator /(double operand) => Offset(dx / operand, dy / operand); + Offset/*!*/ operator /(double/*!*/ operand) => Offset(dx / operand, dy / operand); /// Integer (truncating) division operator. /// /// Returns an offset whose coordinates are the coordinates of the /// left-hand-side operand (an Offset) divided by the scalar right-hand-side /// operand (a double), rounded towards zero. - Offset operator ~/(double operand) => Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble()); + Offset/*!*/ operator ~/(double/*!*/ operand) => Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns an offset whose coordinates are the remainder of dividing the /// coordinates of the left-hand-side operand (an Offset) by the scalar /// right-hand-side operand (a double). - Offset operator %(double operand) => Offset(dx % operand, dy % operand); + Offset/*!*/ operator %(double/*!*/ operand) => Offset(dx % operand, dy % operand); /// Rectangle constructor operator. /// @@ -299,7 +297,7 @@ class Offset extends OffsetBase { /// Rect myRect = Offset.zero & const Size(100.0, 100.0); /// // same as: Rect.fromLTWH(0.0, 0.0, 100.0, 100.0) /// ``` - Rect operator &(Size other) => Rect.fromLTWH(dx, dy, other.width, other.height); + Rect/*!*/ operator &(Size/*!*/ other) => Rect.fromLTWH(dx, dy, other.width, other.height); /// Linearly interpolate between two offsets. /// @@ -316,7 +314,7 @@ class Offset extends OffsetBase { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Offset lerp(Offset a, Offset b, double t) { + static Offset/*!*/ lerp(Offset/*?*/ a, Offset/*?*/ b, double/*!*/ t) { assert(t != null); if (a == null && b == null) return null; @@ -329,17 +327,17 @@ class Offset extends OffsetBase { /// Compares two Offsets for equality. @override - bool operator ==(dynamic other) { + bool/*!*/ operator ==(dynamic other) { return other is Offset && other.dx == dx && other.dy == dy; } @override - int get hashCode => hashValues(dx, dy); + int/*!*/ get hashCode => hashValues(dx, dy); @override - String toString() => 'Offset(${dx?.toStringAsFixed(1)}, ${dy?.toStringAsFixed(1)})'; + String/*!*/ toString() => 'Offset(${dx.toStringAsFixed(1)}, ${dy.toStringAsFixed(1)})'; } /// Holds a 2D floating-point size. @@ -347,11 +345,11 @@ class Offset extends OffsetBase { /// You can think of this as an [Offset] from the origin. class Size extends OffsetBase { /// Creates a [Size] with the given [width] and [height]. - const Size(double width, double height) : super(width, height); + const Size(double/*!*/ width, double/*!*/ height) : super(width, height); /// Creates an instance of [Size] that has the same values as another. // Used by the rendering library's _DebugSize hack. - Size.copy(Size source) : super(source.width, source.height); + Size.copy(Size/*!*/ source) : super(source.width, source.height); /// Creates a square [Size] whose [width] and [height] are the given dimension. /// @@ -359,13 +357,13 @@ class Size extends OffsetBase { /// /// * [Size.fromRadius], which is more convenient when the available size /// is the radius of a circle. - const Size.square(double dimension) : super(dimension, dimension); + const Size.square(double/*!*/ dimension) : super(dimension, dimension); /// Creates a [Size] with the given [width] and an infinite [height]. - const Size.fromWidth(double width) : super(width, double.infinity); + const Size.fromWidth(double/*!*/ width) : super(width, double.infinity); /// Creates a [Size] with the given [height] and an infinite [width]. - const Size.fromHeight(double height) : super(double.infinity, height); + const Size.fromHeight(double/*!*/ height) : super(double.infinity, height); /// Creates a square [Size] whose [width] and [height] are twice the given /// dimension. @@ -375,13 +373,13 @@ class Size extends OffsetBase { /// See also: /// /// * [Size.square], which creates a square with the given dimension. - const Size.fromRadius(double radius) : super(radius * 2.0, radius * 2.0); + const Size.fromRadius(double/*!*/ radius) : super(radius * 2.0, radius * 2.0); /// The horizontal extent of this size. - double get width => _dx; + double/*!*/ get width => _dx; /// The vertical extent of this size. - double get height => _dy; + double/*!*/ get height => _dy; /// The aspect ratio of this size. /// @@ -397,7 +395,7 @@ class Size extends OffsetBase { /// ratio. /// * [FittedBox], a widget that (in most modes) attempts to maintain a /// child widget's aspect ratio while changing its size. - double get aspectRatio { + double/*!*/ get aspectRatio { if (height != 0.0) return width / height; if (width > 0.0) @@ -421,7 +419,7 @@ class Size extends OffsetBase { /// Whether this size encloses a non-zero area. /// /// Negative areas are considered empty. - bool get isEmpty => width <= 0.0 || height <= 0.0; + bool/*!*/ get isEmpty => width <= 0.0 || height <= 0.0; /// Binary subtraction operator for [Size]. /// @@ -439,7 +437,7 @@ class Size extends OffsetBase { /// right-hand-side operand, and a [height] consisting of the [height] of the /// left-hand-side operand minus the [Offset.dy] dimension of the /// right-hand-side operand. - OffsetBase operator -(OffsetBase other) { + OffsetBase/*!*/ operator -(OffsetBase/*!*/ other) { if (other is Size) return Offset(width - other.width, height - other.height); if (other is Offset) @@ -454,41 +452,41 @@ class Size extends OffsetBase { /// right-hand-side operand, an [Offset], and whose [height] is the sum of the /// [height] of the left-hand-side operand and the [Offset.dy] dimension of /// the right-hand-side operand. - Size operator +(Offset other) => Size(width + other.dx, height + other.dy); + Size/*!*/ operator +(Offset/*!*/ other) => Size(width + other.dx, height + other.dy); /// Multiplication operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) multiplied by the scalar right-hand-side operand (a /// [double]). - Size operator *(double operand) => Size(width * operand, height * operand); + Size/*!*/ operator *(double/*!*/ operand) => Size(width * operand, height * operand); /// Division operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) divided by the scalar right-hand-side operand (a /// [double]). - Size operator /(double operand) => Size(width / operand, height / operand); + Size/*!*/ operator /(double/*!*/ operand) => Size(width / operand, height / operand); /// Integer (truncating) division operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) divided by the scalar right-hand-side operand (a /// [double]), rounded towards zero. - Size operator ~/(double operand) => Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble()); + Size/*!*/ operator ~/(double/*!*/ operand) => Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns a [Size] whose dimensions are the remainder of dividing the /// left-hand-side operand (a [Size]) by the scalar right-hand-side operand (a /// [double]). - Size operator %(double operand) => Size(width % operand, height % operand); + Size/*!*/ operator %(double/*!*/ operand) => Size(width % operand, height % operand); /// The lesser of the magnitudes of the [width] and the [height]. - double get shortestSide => math.min(width.abs(), height.abs()); + double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height]. - double get longestSide => math.max(width.abs(), height.abs()); + double/*!*/ get longestSide => math.max(width.abs(), height.abs()); // Convenience methods that do the equivalent of calling the similarly named // methods on a Rect constructed from the given origin and this size. @@ -498,60 +496,60 @@ class Size extends OffsetBase { /// and this [Size]. /// /// See also [Rect.topLeft]. - Offset topLeft(Offset origin) => origin; + Offset/*!*/ topLeft(Offset/*!*/ origin) => origin; /// The offset to the center of the top edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.topCenter]. - Offset topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy); + Offset/*!*/ topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy); /// The offset to the intersection of the top and right edges of the rectangle /// described by the given offset (which is interpreted as the top-left corner) /// and this size. /// /// See also [Rect.topRight]. - Offset topRight(Offset origin) => Offset(origin.dx + width, origin.dy); + Offset/*!*/ topRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy); /// The offset to the center of the left edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.centerLeft]. - Offset centerLeft(Offset origin) => Offset(origin.dx, origin.dy + height / 2.0); + Offset/*!*/ centerLeft(Offset/*!*/ origin) => Offset(origin.dx, origin.dy + height / 2.0); /// The offset to the point halfway between the left and right and the top and /// bottom edges of the rectangle described by the given offset (which is /// interpreted as the top-left corner) and this size. /// /// See also [Rect.center]. - Offset center(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy + height / 2.0); + Offset/*!*/ center(Offset/*!*/ origin) => Offset(origin.dx + width / 2.0, origin.dy + height / 2.0); /// The offset to the center of the right edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.centerLeft]. - Offset centerRight(Offset origin) => Offset(origin.dx + width, origin.dy + height / 2.0); + Offset/*!*/ centerRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy + height / 2.0); /// The offset to the intersection of the bottom and left edges of the /// rectangle described by the given offset (which is interpreted as the /// top-left corner) and this size. /// /// See also [Rect.bottomLeft]. - Offset bottomLeft(Offset origin) => Offset(origin.dx, origin.dy + height); + Offset/*!*/ bottomLeft(Offset/*!*/ origin) => Offset(origin.dx, origin.dy + height); /// The offset to the center of the bottom edge of the rectangle described by /// the given offset (which is interpreted as the top-left corner) and this /// size. /// /// See also [Rect.bottomLeft]. - Offset bottomCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy + height); + Offset/*!*/ bottomCenter(Offset/*!*/ origin) => Offset(origin.dx + width / 2.0, origin.dy + height); /// The offset to the intersection of the bottom and right edges of the /// rectangle described by the given offset (which is interpreted as the /// top-left corner) and this size. /// /// See also [Rect.bottomRight]. - Offset bottomRight(Offset origin) => Offset(origin.dx + width, origin.dy + height); + Offset/*!*/ bottomRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy + height); /// Whether the point specified by the given offset (which is assumed to be /// relative to the top left of the size) lies between the left and right and @@ -559,12 +557,12 @@ class Size extends OffsetBase { /// /// Rectangles include their top and left edges but exclude their bottom and /// right edges. - bool contains(Offset offset) { + bool/*!*/ contains(Offset/*!*/ offset) { return offset.dx >= 0.0 && offset.dx < width && offset.dy >= 0.0 && offset.dy < height; } /// A [Size] with the [width] and [height] swapped. - Size get flipped => Size(height, width); + Size/*!*/ get flipped => Size(height, width); /// Linearly interpolate between two sizes /// @@ -581,7 +579,7 @@ class Size extends OffsetBase { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Size lerp(Size a, Size b, double t) { + static Size/*!*/ lerp(Size/*?*/ a, Size/*?*/ b, double/*!*/ t) { assert(t != null); if (a == null && b == null) return null; @@ -595,17 +593,17 @@ class Size extends OffsetBase { /// Compares two Sizes for equality. // We don't compare the runtimeType because of _DebugSize in the framework. @override - bool operator ==(dynamic other) { + bool/*!*/ operator ==(dynamic other) { return other is Size && other._dx == _dx && other._dy == _dy; } @override - int get hashCode => hashValues(_dx, _dy); + int/*!*/ get hashCode => hashValues(_dx, _dy); @override - String toString() => 'Size(${width?.toStringAsFixed(1)}, ${height?.toStringAsFixed(1)})'; + String/*!*/ toString() => 'Size(${width.toStringAsFixed(1)}, ${height.toStringAsFixed(1)})'; } /// An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates @@ -620,27 +618,23 @@ class Size extends OffsetBase { class Rect { /// Construct a rectangle from its left, top, right, and bottom edges. @pragma('vm:entry-point') - const Rect.fromLTRB(double left, double top, double right, double bottom) - : left = left ?? 0.0, - right = right ?? 0.0, - top = top ?? 0.0, - bottom = bottom ?? 0.0, - assert(left != null), - assert(top != null), - assert(right != null), - assert(bottom != null); + const Rect.fromLTRB(this.left, this.top, this.right, this.bottom) + : assert(left != null), + assert(top != null), + assert(right != null), + assert(bottom != null); /// Construct a rectangle from its left and top edges, its width, and its /// height. /// /// To construct a [Rect] from an [Offset] and a [Size], you can use the /// rectangle constructor operator `&`. See [Offset.&]. - const Rect.fromLTWH(double left, double top, double width, double height) : this.fromLTRB(left, top, left + width, top + height); + const Rect.fromLTWH(double/*!*/ left, double/*!*/ top, double/*!*/ width, double/*!*/ height) : this.fromLTRB(left, top, left + width, top + height); /// Construct a rectangle that bounds the given circle. /// /// The `center` argument is assumed to be an offset from the origin. - Rect.fromCircle({ Offset center, double radius }) : this.fromCenter( + Rect.fromCircle({ Offset/*!*/ center, double/*!*/ radius }) : this.fromCenter( center: center, width: radius * 2, height: radius * 2, @@ -649,7 +643,7 @@ class Rect { /// Constructs a rectangle from its center point, width, and height. /// /// The `center` argument is assumed to be an offset from the origin. - Rect.fromCenter({ Offset center, double width, double height }) : this.fromLTRB( + Rect.fromCenter({ Offset center/*!*/, double/*!*/ width, double/*!*/ height }) : this.fromLTRB( center.dx - width / 2, center.dy - height / 2, center.dx + width / 2, @@ -658,39 +652,39 @@ class Rect { /// Construct the smallest rectangle that encloses the given offsets, treating /// them as vectors from the origin. - Rect.fromPoints(Offset a, Offset b) : this.fromLTRB( + Rect.fromPoints(Offset/*!*/ a, Offset/*!*/ b) : this.fromLTRB( math.min(a.dx, b.dx), math.min(a.dy, b.dy), math.max(a.dx, b.dx), math.max(a.dy, b.dy), ); - Float32List get _value32 => Float32List.fromList([left, top, right, bottom]); + Float32List/*!*/ get _value32 => Float32List.fromList([left, top, right, bottom]); /// The offset of the left edge of this rectangle from the x axis. - final double left; + final double/*!*/ left; /// The offset of the top edge of this rectangle from the y axis. - final double top; + final double/*!*/ top; /// The offset of the right edge of this rectangle from the x axis. - final double right; + final double/*!*/ right; /// The offset of the bottom edge of this rectangle from the y axis. - final double bottom; + final double/*!*/ bottom; /// The distance between the left and right edges of this rectangle. - double get width => right - left; + double/*!*/ get width => right - left; /// The distance between the top and bottom edges of this rectangle. - double get height => bottom - top; + double/*!*/ get height => bottom - top; /// The distance between the upper-left corner and the lower-right corner of /// this rectangle. - Size get size => Size(width, height); + Size/*!*/ get size => Size(width, height); /// Whether any of the dimensions are `NaN`. - bool get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN; + bool/*!*/ get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN; /// A rectangle with left, top, right, and bottom edges all at zero. static const Rect zero = Rect.fromLTRB(0.0, 0.0, 0.0, 0.0); @@ -705,7 +699,7 @@ class Rect { /// Whether any of the coordinates of this rectangle are equal to positive infinity. // included for consistency with Offset and Size - bool get isInfinite { + bool/*!*/ get isInfinite { return left >= double.infinity || top >= double.infinity || right >= double.infinity @@ -713,17 +707,17 @@ class Rect { } /// Whether all coordinates of this rectangle are finite. - bool get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; + bool/*!*/ get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; /// Whether this rectangle encloses a non-zero area. Negative areas are /// considered empty. - bool get isEmpty => left >= right || top >= bottom; + bool/*!*/ get isEmpty => left >= right || top >= bottom; /// Returns a new rectangle translated by the given offset. /// /// To translate a rectangle by separate x and y components rather than by an /// [Offset], consider [translate]. - Rect shift(Offset offset) { + Rect/*!*/ shift(Offset/*!*/ offset) { return Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.dx, bottom + offset.dy); } @@ -732,23 +726,23 @@ class Rect { /// /// To translate a rectangle by an [Offset] rather than by separate x and y /// components, consider [shift]. - Rect translate(double translateX, double translateY) { + Rect/*!*/ translate(double/*!*/ translateX, double/*!*/ translateY) { return Rect.fromLTRB(left + translateX, top + translateY, right + translateX, bottom + translateY); } /// Returns a new rectangle with edges moved outwards by the given delta. - Rect inflate(double delta) { + Rect/*!*/ inflate(double/*!*/ delta) { return Rect.fromLTRB(left - delta, top - delta, right + delta, bottom + delta); } /// Returns a new rectangle with edges moved inwards by the given delta. - Rect deflate(double delta) => inflate(-delta); + Rect/*!*/ deflate(double/*!*/ delta) => inflate(-delta); /// Returns a new rectangle that is the intersection of the given /// rectangle and this rectangle. The two rectangles must overlap /// for this to be meaningful. If the two rectangles do not overlap, /// then the resulting Rect will have a negative width or height. - Rect intersect(Rect other) { + Rect/*!*/ intersect(Rect/*!*/ other) { return Rect.fromLTRB( math.max(left, other.left), math.max(top, other.top), @@ -759,7 +753,7 @@ class Rect { /// Returns a new rectangle which is the bounding box containing this /// rectangle and the given rectangle. - Rect expandToInclude(Rect other) { + Rect/*!*/ expandToInclude(Rect/*!*/ other) { return Rect.fromLTRB( math.min(left, other.left), math.min(top, other.top), @@ -769,7 +763,7 @@ class Rect { } /// Whether `other` has a nonzero area of overlap with this rectangle. - bool overlaps(Rect other) { + bool/*!*/ overlaps(Rect/*!*/ other) { if (right <= other.left || other.right <= left) return false; if (bottom <= other.top || other.bottom <= top) @@ -779,57 +773,57 @@ class Rect { /// The lesser of the magnitudes of the [width] and the [height] of this /// rectangle. - double get shortestSide => math.min(width.abs(), height.abs()); + double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height] of this /// rectangle. - double get longestSide => math.max(width.abs(), height.abs()); + double/*!*/ get longestSide => math.max(width.abs(), height.abs()); /// The offset to the intersection of the top and left edges of this rectangle. /// /// See also [Size.topLeft]. - Offset get topLeft => Offset(left, top); + Offset/*!*/ get topLeft => Offset(left, top); /// The offset to the center of the top edge of this rectangle. /// /// See also [Size.topCenter]. - Offset get topCenter => Offset(left + width / 2.0, top); + Offset/*!*/ get topCenter => Offset(left + width / 2.0, top); /// The offset to the intersection of the top and right edges of this rectangle. /// /// See also [Size.topRight]. - Offset get topRight => Offset(right, top); + Offset/*!*/ get topRight => Offset(right, top); /// The offset to the center of the left edge of this rectangle. /// /// See also [Size.centerLeft]. - Offset get centerLeft => Offset(left, top + height / 2.0); + Offset/*!*/ get centerLeft => Offset(left, top + height / 2.0); /// The offset to the point halfway between the left and right and the top and /// bottom edges of this rectangle. /// /// See also [Size.center]. - Offset get center => Offset(left + width / 2.0, top + height / 2.0); + Offset/*!*/ get center => Offset(left + width / 2.0, top + height / 2.0); /// The offset to the center of the right edge of this rectangle. /// /// See also [Size.centerLeft]. - Offset get centerRight => Offset(right, top + height / 2.0); + Offset/*!*/ get centerRight => Offset(right, top + height / 2.0); /// The offset to the intersection of the bottom and left edges of this rectangle. /// /// See also [Size.bottomLeft]. - Offset get bottomLeft => Offset(left, bottom); + Offset/*!*/ get bottomLeft => Offset(left, bottom); /// The offset to the center of the bottom edge of this rectangle. /// /// See also [Size.bottomLeft]. - Offset get bottomCenter => Offset(left + width / 2.0, bottom); + Offset/*!*/ get bottomCenter => Offset(left + width / 2.0, bottom); /// The offset to the intersection of the bottom and right edges of this rectangle. /// /// See also [Size.bottomRight]. - Offset get bottomRight => Offset(right, bottom); + Offset/*!*/ get bottomRight => Offset(right, bottom); /// Whether the point specified by the given offset (which is assumed to be /// relative to the origin) lies between the left and right and the top and @@ -837,7 +831,7 @@ class Rect { /// /// Rectangles include their top and left edges but exclude their bottom and /// right edges. - bool contains(Offset offset) { + bool/*!*/ contains(Offset/*!*/ offset) { return offset.dx >= left && offset.dx < right && offset.dy >= top && offset.dy < bottom; } @@ -856,7 +850,7 @@ class Rect { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Rect lerp(Rect a, Rect b, double t) { + static Rect/*!*/ lerp(Rect/*?*/ a, Rect/*?*/ b, double/*!*/ t) { assert(t != null); if (a == null && b == null) return null; @@ -875,7 +869,7 @@ class Rect { } @override - bool operator ==(dynamic other) { + bool/*!*/ operator ==(dynamic other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) @@ -888,25 +882,25 @@ class Rect { } @override - int get hashCode => hashValues(left, top, right, bottom); + int/*!*/ get hashCode => hashValues(left, top, right, bottom); @override - String toString() => 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})'; + String/*!*/ toString() => 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})'; } /// A radius for either circular or elliptical shapes. class Radius { /// Constructs a circular radius. [x] and [y] will have the same radius value. - const Radius.circular(double radius) : this.elliptical(radius, radius); + const Radius.circular(double/*!*/ radius) : this.elliptical(radius, radius); /// Constructs an elliptical radius with the given radii. const Radius.elliptical(this.x, this.y); /// The radius value on the horizontal axis. - final double x; + final double/*!*/ x; /// The radius value on the vertical axis. - final double y; + final double/*!*/ y; /// A radius with [x] and [y] values set to zero. /// @@ -921,49 +915,49 @@ class Radius { /// occur as part of expressions. For example, negating a radius of one pixel /// and then adding the result to another radius is equivalent to subtracting /// a radius of one pixel from the other. - Radius operator -() => Radius.elliptical(-x, -y); + Radius/*!*/ operator -() => Radius.elliptical(-x, -y); /// Binary subtraction operator. /// /// Returns a radius whose [x] value is the left-hand-side operand's [x] /// minus the right-hand-side operand's [x] and whose [y] value is the /// left-hand-side operand's [y] minus the right-hand-side operand's [y]. - Radius operator -(Radius other) => Radius.elliptical(x - other.x, y - other.y); + Radius/*!*/ operator -(Radius/*!*/ other) => Radius.elliptical(x - other.x, y - other.y); /// Binary addition operator. /// /// Returns a radius whose [x] value is the sum of the [x] values of the /// two operands, and whose [y] value is the sum of the [y] values of the /// two operands. - Radius operator +(Radius other) => Radius.elliptical(x + other.x, y + other.y); + Radius/*!*/ operator +(Radius/*!*/ other) => Radius.elliptical(x + other.x, y + other.y); /// Multiplication operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) multiplied by the scalar /// right-hand-side operand (a double). - Radius operator *(double operand) => Radius.elliptical(x * operand, y * operand); + Radius/*!*/ operator *(double/*!*/ operand) => Radius.elliptical(x * operand, y * operand); /// Division operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) divided by the scalar right-hand-side /// operand (a double). - Radius operator /(double operand) => Radius.elliptical(x / operand, y / operand); + Radius/*!*/ operator /(double/*!*/ operand) => Radius.elliptical(x / operand, y / operand); /// Integer (truncating) division operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) divided by the scalar right-hand-side /// operand (a double), rounded towards zero. - Radius operator ~/(double operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); + Radius/*!*/ operator ~/(double/*!*/ operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns a radius whose coordinates are the remainder of dividing the /// coordinates of the left-hand-side operand (a radius) by the scalar /// right-hand-side operand (a double). - Radius operator %(double operand) => Radius.elliptical(x % operand, y % operand); + Radius/*!*/ operator %(double/*!*/ operand) => Radius.elliptical(x % operand, y % operand); /// Linearly interpolate between two radii. /// @@ -980,7 +974,7 @@ class Radius { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Radius lerp(Radius a, Radius b, double t) { + static Radius/*!*/ lerp(Radius/*?*/ a, Radius/*?*/ b, double/*!*/ t) { assert(t != null); if (a == null && b == null) return null; @@ -997,7 +991,7 @@ class Radius { } @override - bool operator ==(dynamic other) { + bool/*!*/ operator ==(dynamic other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) @@ -1009,10 +1003,10 @@ class Radius { } @override - int get hashCode => hashValues(x, y); + int/*!*/ get hashCode => hashValues(x, y); @override - String toString() { + String/*!*/ toString() { return x == y ? 'Radius.circular(${x.toStringAsFixed(1)})' : 'Radius.elliptical(${x.toStringAsFixed(1)}, ' '${y.toStringAsFixed(1)})'; @@ -1023,8 +1017,8 @@ class Radius { class RRect { /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and the same radii along its horizontal axis and its vertical axis. - const RRect.fromLTRBXY(double left, double top, double right, double bottom, - double radiusX, double radiusY) : this._raw( + const RRect.fromLTRBXY(double/*!*/ left, double/*!*/ top, double/*!*/ right, double/*!*/ bottom, + double/*!*/ radiusX, double/*!*/ radiusY) : this._raw( top: top, left: left, right: right, @@ -1041,8 +1035,8 @@ class RRect { /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and the same radius in each corner. - RRect.fromLTRBR(double left, double top, double right, double bottom, - Radius radius) + RRect.fromLTRBR(double/*!*/ left, double/*!*/ top, double/*!*/ right, double/*!*/ bottom, + Radius/*!*/ radius) : this._raw( top: top, left: left, @@ -1060,7 +1054,7 @@ class RRect { /// Construct a rounded rectangle from its bounding box and the same radii /// along its horizontal axis and its vertical axis. - RRect.fromRectXY(Rect rect, double radiusX, double radiusY) + RRect.fromRectXY(Rect/*!*/ rect, double/*!*/ radiusX, double/*!*/ radiusY) : this._raw( top: rect.top, left: rect.left, @@ -1078,7 +1072,7 @@ class RRect { /// Construct a rounded rectangle from its bounding box and a radius that is /// the same in each corner. - RRect.fromRectAndRadius(Rect rect, Radius radius) + RRect.fromRectAndRadius(Rect/*!*/ rect, Radius/*!*/ radius) : this._raw( top: rect.top, left: rect.left, @@ -1099,14 +1093,14 @@ class RRect { /// /// The corner radii default to [Radius.zero], i.e. right-angled corners. RRect.fromLTRBAndCorners( - double left, - double top, - double right, - double bottom, { - Radius topLeft = Radius.zero, - Radius topRight = Radius.zero, - Radius bottomRight = Radius.zero, - Radius bottomLeft = Radius.zero, + double/*!*/ left, + double/*!*/ top, + double/*!*/ right, + double/*!*/ bottom, { + Radius/*!*/ topLeft = Radius.zero, + Radius/*!*/ topRight = Radius.zero, + Radius/*!*/ bottomRight = Radius.zero, + Radius/*!*/ bottomLeft = Radius.zero, }) : this._raw( top: top, left: left, @@ -1127,12 +1121,12 @@ class RRect { /// /// The corner radii default to [Radius.zero], i.e. right-angled corners RRect.fromRectAndCorners( - Rect rect, + Rect/*!*/ rect, { - Radius topLeft = Radius.zero, - Radius topRight = Radius.zero, - Radius bottomRight = Radius.zero, - Radius bottomLeft = Radius.zero + Radius/*!*/ topLeft = Radius.zero, + Radius/*!*/ topRight = Radius.zero, + Radius/*!*/ bottomRight = Radius.zero, + Radius/*!*/ bottomLeft = Radius.zero } ) : this._raw( top: rect.top, @@ -1191,58 +1185,58 @@ class RRect { ]); /// The offset of the left edge of this rectangle from the x axis. - final double left; + final double/*!*/ left; /// The offset of the top edge of this rectangle from the y axis. - final double top; + final double/*!*/ top; /// The offset of the right edge of this rectangle from the x axis. - final double right; + final double/*!*/ right; /// The offset of the bottom edge of this rectangle from the y axis. - final double bottom; + final double/*!*/ bottom; /// The top-left horizontal radius. - final double tlRadiusX; + final double/*!*/ tlRadiusX; /// The top-left vertical radius. - final double tlRadiusY; + final double/*!*/ tlRadiusY; /// The top-left [Radius]. - Radius get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY); + Radius/*!*/ get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY); /// The top-right horizontal radius. - final double trRadiusX; + final double/*!*/ trRadiusX; /// The top-right vertical radius. - final double trRadiusY; + final double/*!*/ trRadiusY; /// The top-right [Radius]. - Radius get trRadius => Radius.elliptical(trRadiusX, trRadiusY); + Radius/*!*/ get trRadius => Radius.elliptical(trRadiusX, trRadiusY); /// The bottom-right horizontal radius. - final double brRadiusX; + final double/*!*/ brRadiusX; /// The bottom-right vertical radius. - final double brRadiusY; + final double/*!*/ brRadiusY; /// The bottom-right [Radius]. - Radius get brRadius => Radius.elliptical(brRadiusX, brRadiusY); + Radius/*!*/ get brRadius => Radius.elliptical(brRadiusX, brRadiusY); /// The bottom-left horizontal radius. - final double blRadiusX; + final double/*!*/ blRadiusX; /// The bottom-left vertical radius. - final double blRadiusY; + final double/*!*/ blRadiusY; /// The bottom-left [Radius]. - Radius get blRadius => Radius.elliptical(blRadiusX, blRadiusY); + Radius/*!*/ get blRadius => Radius.elliptical(blRadiusX, blRadiusY); /// A rounded rectangle with all the values set to zero. static const RRect zero = RRect._raw(); /// Returns a new [RRect] translated by the given offset. - RRect shift(Offset offset) { + RRect/*!*/ shift(Offset/*!*/ offset) { return RRect._raw( left: left + offset.dx, top: top + offset.dy, @@ -1261,7 +1255,7 @@ class RRect { /// Returns a new [RRect] with edges and radii moved outwards by the given /// delta. - RRect inflate(double delta) { + RRect/*!*/ inflate(double/*!*/ delta) { return RRect._raw( left: left - delta, top: top - delta, @@ -1279,22 +1273,22 @@ class RRect { } /// Returns a new [RRect] with edges and radii moved inwards by the given delta. - RRect deflate(double delta) => inflate(-delta); + RRect/*!*/ deflate(double/*!*/ delta) => inflate(-delta); /// The distance between the left and right edges of this rectangle. - double get width => right - left; + double/*!*/ get width => right - left; /// The distance between the top and bottom edges of this rectangle. - double get height => bottom - top; + double/*!*/ get height => bottom - top; /// The bounding box of this rounded rectangle (the rectangle with no rounded corners). - Rect get outerRect => Rect.fromLTRB(left, top, right, bottom); + Rect/*!*/ get outerRect => Rect.fromLTRB(left, top, right, bottom); /// The non-rounded rectangle that is constrained by the smaller of the two /// diagonals, with each diagonal traveling through the middle of the curve /// corners. The middle of a corner is the intersection of the curve with its /// respective quadrant bisector. - Rect get safeInnerRect { + Rect/*!*/ get safeInnerRect { const double kInsetFactor = 0.29289321881; // 1-cos(pi/4) final double leftRadius = math.max(blRadiusX, tlRadiusX); @@ -1316,7 +1310,7 @@ class RRect { /// intersection of the [wideMiddleRect] and the [tallMiddleRect]. If any of /// the intersections are void, the resulting [Rect] will have negative width /// or height. - Rect get middleRect { + Rect/*!*/ get middleRect { final double leftRadius = math.max(blRadiusX, tlRadiusX); final double topRadius = math.max(tlRadiusY, trRadiusY); final double rightRadius = math.max(trRadiusX, brRadiusX); @@ -1333,7 +1327,7 @@ class RRect { /// has the full width of the rounded rectangle. If the rounded rectangle does /// not have an axis-aligned intersection of its left and right side, the /// resulting [Rect] will have negative width or height. - Rect get wideMiddleRect { + Rect/*!*/ get wideMiddleRect { final double topRadius = math.max(tlRadiusY, trRadiusY); final double bottomRadius = math.max(brRadiusY, blRadiusY); return Rect.fromLTRB( @@ -1348,7 +1342,7 @@ class RRect { /// has the full height of the rounded rectangle. If the rounded rectangle /// does not have an axis-aligned intersection of its top and bottom side, the /// resulting [Rect] will have negative width or height. - Rect get tallMiddleRect { + Rect/*!*/ get tallMiddleRect { final double leftRadius = math.max(blRadiusX, tlRadiusX); final double rightRadius = math.max(trRadiusX, brRadiusX); return Rect.fromLTRB( @@ -1361,14 +1355,14 @@ class RRect { /// Whether this rounded rectangle encloses a non-zero area. /// Negative areas are considered empty. - bool get isEmpty => left >= right || top >= bottom; + bool/*!*/ get isEmpty => left >= right || top >= bottom; /// Whether all coordinates of this rounded rectangle are finite. - bool get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; + bool/*!*/ get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; /// Whether this rounded rectangle is a simple rectangle with zero /// corner radii. - bool get isRect { + bool/*!*/ get isRect { return (tlRadiusX == 0.0 || tlRadiusY == 0.0) && (trRadiusX == 0.0 || trRadiusY == 0.0) && (blRadiusX == 0.0 || blRadiusY == 0.0) && @@ -1376,7 +1370,7 @@ class RRect { } /// Whether this rounded rectangle has a side with no straight section. - bool get isStadium { + bool/*!*/ get isStadium { return tlRadius == trRadius && trRadius == brRadius && brRadius == blRadius @@ -1384,7 +1378,7 @@ class RRect { } /// Whether this rounded rectangle has no side with a straight section. - bool get isEllipse { + bool/*!*/ get isEllipse { return tlRadius == trRadius && trRadius == brRadius && brRadius == blRadius @@ -1393,24 +1387,24 @@ class RRect { } /// Whether this rounded rectangle would draw as a circle. - bool get isCircle => width == height && isEllipse; + bool/*!*/ get isCircle => width == height && isEllipse; /// The lesser of the magnitudes of the [width] and the [height] of this /// rounded rectangle. - double get shortestSide => math.min(width.abs(), height.abs()); + double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height] of this /// rounded rectangle. - double get longestSide => math.max(width.abs(), height.abs()); + double/*!*/ get longestSide => math.max(width.abs(), height.abs()); /// Whether any of the dimensions are `NaN`. - bool get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN || + bool/*!*/ get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN || trRadiusX.isNaN || trRadiusY.isNaN || tlRadiusX.isNaN || tlRadiusY.isNaN || brRadiusX.isNaN || brRadiusY.isNaN || blRadiusX.isNaN || blRadiusY.isNaN; /// The offset to the point halfway between the left and right and the top and /// bottom edges of this rectangle. - Offset get center => Offset(left + width / 2.0, top + height / 2.0); + Offset/*!*/ get center => Offset(left + width / 2.0, top + height / 2.0); // Returns the minimum between min and scale to which radius1 and radius2 // should be scaled with in order not to exceed the limit. @@ -1430,7 +1424,7 @@ class RRect { /// /// See the [Skia scaling implementation](https://github.com/google/skia/blob/master/src/core/SkRRect.cpp) /// for more details. - RRect scaleRadii() { + RRect/*!*/ scaleRadii() { double scale = 1.0; scale = _getMin(scale, blRadiusY, tlRadiusY, height); scale = _getMin(scale, tlRadiusX, trRadiusX, width); @@ -1477,7 +1471,7 @@ class RRect { /// radii the first time it is called on a particular [RRect] instance. When /// using this method, prefer to reuse existing [RRect]s rather than /// recreating the object each time. - bool contains(Offset point) { + bool/*!*/ contains(Offset/*!*/ point) { if (point.dx < left || point.dx >= right || point.dy < top || point.dy >= bottom) return false; // outside bounding box @@ -1540,7 +1534,7 @@ class RRect { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static RRect lerp(RRect a, RRect b, double t) { + static RRect/*!*/ lerp(RRect/*?*/ a, RRect/*?*/ b, double/*!*/ t) { assert(t != null); if (a == null && b == null) return null; @@ -1594,7 +1588,7 @@ class RRect { } @override - bool operator ==(dynamic other) { + bool/*!*/ operator ==(dynamic other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) @@ -1615,12 +1609,12 @@ class RRect { } @override - int get hashCode => hashValues(left, top, right, bottom, + int/*!*/ get hashCode => hashValues(left, top, right, bottom, tlRadiusX, tlRadiusY, trRadiusX, trRadiusY, blRadiusX, blRadiusY, brRadiusX, brRadiusY); @override - String toString() { + String/*!*/ toString() { final String rect = '${left.toStringAsFixed(1)}, ' '${top.toStringAsFixed(1)}, ' '${right.toStringAsFixed(1)}, ' @@ -1672,7 +1666,7 @@ class RSTransform { /// computations of the sine and cosine of the rotation so that they can be /// reused over multiple calls to this constructor, it may be more efficient /// to directly use this constructor instead. - RSTransform(double scos, double ssin, double tx, double ty) { + RSTransform(double/*!*/ scos, double/*!*/ ssin, double/*!*/ tx, double/*!*/ ty) { _value ..[0] = scos ..[1] = ssin @@ -1700,12 +1694,12 @@ class RSTransform { /// over multiple [RSTransform] objects, it may be more efficient to directly /// use the more direct [new RSTransform] constructor instead. factory RSTransform.fromComponents({ - double rotation, - double scale, - double anchorX, - double anchorY, - double translateX, - double translateY + double/*!*/ rotation, + double/*!*/ scale, + double/*!*/ anchorX, + double/*!*/ anchorY, + double/*!*/ translateX, + double/*!*/ translateY }) { final double scos = math.cos(rotation) * scale; final double ssin = math.sin(rotation) * scale; @@ -1717,18 +1711,18 @@ class RSTransform { final Float32List _value = Float32List(4); /// The cosine of the rotation multiplied by the scale factor. - double get scos => _value[0]; + double/*!*/ get scos => _value[0]; /// The sine of the rotation multiplied by that same scale factor. - double get ssin => _value[1]; + double/*!*/ get ssin => _value[1]; /// The x coordinate of the translation, minus [scos] multiplied by the /// x-coordinate of the rotation point, plus [ssin] multiplied by the /// y-coordinate of the rotation point. - double get tx => _value[2]; + double/*!*/ get tx => _value[2]; /// The y coordinate of the translation, minus [ssin] multiplied by the /// x-coordinate of the rotation point, minus [scos] multiplied by the /// y-coordinate of the rotation point. - double get ty => _value[3]; + double/*!*/ get ty => _value[3]; } diff --git a/engine/src/flutter/lib/web_ui/lib/src/ui/geometry.dart b/engine/src/flutter/lib/web_ui/lib/src/ui/geometry.dart index 93e18e4e1e..a59afcb544 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/ui/geometry.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/ui/geometry.dart @@ -13,11 +13,12 @@ abstract class OffsetBase { /// /// The first argument sets the horizontal component, and the second the /// vertical component. - const OffsetBase(double dx, double dy) - : _dx = dx, _dy = dy; + const OffsetBase(this._dx, this._dy) + : assert(_dx != null), + assert(_dy != null); - final double _dx; - final double _dy; + final double/*!*/ _dx; + final double/*!*/ _dy; /// Returns true if either component is [double.infinity], and false if both /// are finite (or negative infinity, or NaN). @@ -28,7 +29,7 @@ abstract class OffsetBase { /// See also: /// /// * [isFinite], which is true if both components are finite (and not NaN). - bool get isInfinite => _dx >= double.infinity || _dy >= double.infinity; + bool/*!*/ get isInfinite => _dx >= double.infinity || _dy >= double.infinity; /// Whether both components are finite (neither infinite nor NaN). /// @@ -36,7 +37,7 @@ abstract class OffsetBase { /// /// * [isInfinite], which returns true if either component is equal to /// positive infinity. - bool get isFinite => _dx.isFinite && _dy.isFinite; + bool/*!*/ get isFinite => _dx.isFinite && _dy.isFinite; /// Less-than operator. Compares an [Offset] or [Size] to another [Offset] or /// [Size], and returns true if both the horizontal and vertical values of the @@ -45,7 +46,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator <(OffsetBase other) => _dx < other._dx && _dy < other._dy; + bool/*!*/ operator <(OffsetBase/*!*/ other) => _dx < other._dx && _dy < other._dy; /// Less-than-or-equal-to operator. Compares an [Offset] or [Size] to another /// [Offset] or [Size], and returns true if both the horizontal and vertical @@ -55,7 +56,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator <=(OffsetBase other) => _dx <= other._dx && _dy <= other._dy; + bool/*!*/ operator <=(OffsetBase/*!*/ other) => _dx <= other._dx && _dy <= other._dy; /// Greater-than operator. Compares an [Offset] or [Size] to another [Offset] /// or [Size], and returns true if both the horizontal and vertical values of @@ -65,7 +66,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator >(OffsetBase other) => _dx > other._dx && _dy > other._dy; + bool/*!*/ operator >(OffsetBase/*!*/ other) => _dx > other._dx && _dy > other._dy; /// Greater-than-or-equal-to operator. Compares an [Offset] or [Size] to /// another [Offset] or [Size], and returns true if both the horizontal and @@ -75,27 +76,24 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool operator >=(OffsetBase other) => _dx > other._dx && _dy >= other._dy; + bool/*!*/ operator >=(OffsetBase/*!*/ other) => _dx >= other._dx && _dy >= other._dy; /// Equality operator. Compares an [Offset] or [Size] to another [Offset] or /// [Size], and returns true if the horizontal and vertical values of the /// left-hand-side operand are equal to the horizontal and vertical values of /// the right-hand-side operand respectively. Returns false otherwise. @override - bool operator ==(dynamic other) { - if (other is! OffsetBase) { - return false; - } - final OffsetBase typedOther = other; - return _dx == typedOther._dx && _dy == typedOther._dy; + bool/*!*/ operator ==(dynamic other) { + return other is OffsetBase + && other._dx == _dx + && other._dy == _dy; } @override - int get hashCode => hashValues(_dx, _dy); + int/*!*/ get hashCode => hashValues(_dx, _dy); @override - String toString() => - '$runtimeType(${_dx?.toStringAsFixed(1)}, ${_dy?.toStringAsFixed(1)})'; + String/*!*/ toString() => 'OffsetBase(${_dx.toStringAsFixed(1)}, ${_dy.toStringAsFixed(1)})'; } /// An immutable 2D floating-point offset. @@ -122,38 +120,37 @@ abstract class OffsetBase { class Offset extends OffsetBase { /// Creates an offset. The first argument sets [dx], the horizontal component, /// and the second sets [dy], the vertical component. - const Offset(double dx, double dy) : super(dx, dy); + const Offset(double/*!*/ dx, double/*!*/ dy) : super(dx, dy); /// Creates an offset from its [direction] and [distance]. /// /// The direction is in radians clockwise from the positive x-axis. /// /// The distance can be omitted, to create a unit vector (distance = 1.0). - factory Offset.fromDirection(double direction, [double distance = 1.0]) { - return Offset( - distance * math.cos(direction), distance * math.sin(direction)); + factory Offset.fromDirection(double/*!*/ direction, [ double/*!*/ distance = 1.0 ]) { + return Offset(distance * math.cos(direction), distance * math.sin(direction)); } /// The x component of the offset. /// /// The y component is given by [dy]. - double get dx => _dx; + double/*!*/ get dx => _dx; /// The y component of the offset. /// /// The x component is given by [dx]. - double get dy => _dy; + double/*!*/ get dy => _dy; /// The magnitude of the offset. /// /// If you need this value to compare it to another [Offset]'s distance, /// consider using [distanceSquared] instead, since it is cheaper to compute. - double get distance => math.sqrt(dx * dx + dy * dy); + double/*!*/ get distance => math.sqrt(dx * dx + dy * dy); /// The square of the magnitude of the offset. /// /// This is cheaper than computing the [distance] itself. - double get distanceSquared => dx * dx + dy * dy; + double/*!*/ get distanceSquared => dx * dx + dy * dy; /// The angle of this offset as radians clockwise from the positive x-axis, in /// the range -[pi] to [pi], assuming positive values of the x-axis go to the @@ -182,7 +179,7 @@ class Offset extends OffsetBase { /// /// * [distance], to compute the magnitude of the vector. /// * [Canvas.rotate], which uses the same convention for its angle. - double get direction => math.atan2(dy, dx); + double/*!*/ get direction => math.atan2(dy, dx); /// An offset with zero magnitude. /// @@ -216,8 +213,7 @@ class Offset extends OffsetBase { /// Offset a = const Offset(10.0, 10.0); /// Offset b = -a; // same as: a.scale(-1.0, -1.0) /// ``` - Offset scale(double scaleX, double scaleY) => - Offset(dx * scaleX, dy * scaleY); + Offset/*!*/ scale(double/*!*/ scaleX, double/*!*/ scaleY) => Offset(dx * scaleX, dy * scaleY); /// Returns a new offset with translateX added to the x component and /// translateY added to the y component. @@ -231,8 +227,7 @@ class Offset extends OffsetBase { /// Offset c = a + b; // same as: a.translate(b.dx, b.dy) /// Offset d = a - b; // same as: a.translate(-b.dx, -b.dy) /// ``` - Offset translate(double translateX, double translateY) => - Offset(dx + translateX, dy + translateY); + Offset/*!*/ translate(double/*!*/ translateX, double/*!*/ translateY) => Offset(dx + translateX, dy + translateY); /// Unary negation operator. /// @@ -240,7 +235,7 @@ class Offset extends OffsetBase { /// /// If the [Offset] represents an arrow on a plane, this operator returns the /// same arrow but pointing in the reverse direction. - Offset operator -() => Offset(-dx, -dy); + Offset/*!*/ operator -() => Offset(-dx, -dy); /// Binary subtraction operator. /// @@ -249,7 +244,7 @@ class Offset extends OffsetBase { /// left-hand-side operand's [dy] minus the right-hand-side operand's [dy]. /// /// See also [translate]. - Offset operator -(Offset other) => Offset(dx - other.dx, dy - other.dy); + Offset/*!*/ operator -(Offset/*!*/ other) => Offset(dx - other.dx, dy - other.dy); /// Binary addition operator. /// @@ -258,7 +253,7 @@ class Offset extends OffsetBase { /// two operands. /// /// See also [translate]. - Offset operator +(Offset other) => Offset(dx + other.dx, dy + other.dy); + Offset/*!*/ operator +(Offset/*!*/ other) => Offset(dx + other.dx, dy + other.dy); /// Multiplication operator. /// @@ -267,7 +262,7 @@ class Offset extends OffsetBase { /// right-hand-side operand (a double). /// /// See also [scale]. - Offset operator *(double operand) => Offset(dx * operand, dy * operand); + Offset/*!*/ operator *(double/*!*/ operand) => Offset(dx * operand, dy * operand); /// Division operator. /// @@ -276,22 +271,21 @@ class Offset extends OffsetBase { /// operand (a double). /// /// See also [scale]. - Offset operator /(double operand) => Offset(dx / operand, dy / operand); + Offset/*!*/ operator /(double/*!*/ operand) => Offset(dx / operand, dy / operand); /// Integer (truncating) division operator. /// /// Returns an offset whose coordinates are the coordinates of the /// left-hand-side operand (an Offset) divided by the scalar right-hand-side /// operand (a double), rounded towards zero. - Offset operator ~/(double operand) => - Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble()); + Offset/*!*/ operator ~/(double/*!*/ operand) => Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns an offset whose coordinates are the remainder of dividing the /// coordinates of the left-hand-side operand (an Offset) by the scalar /// right-hand-side operand (a double). - Offset operator %(double operand) => Offset(dx % operand, dy % operand); + Offset/*!*/ operator %(double/*!*/ operand) => Offset(dx % operand, dy % operand); /// Rectangle constructor operator. /// @@ -301,10 +295,9 @@ class Offset extends OffsetBase { /// /// ```dart /// Rect myRect = Offset.zero & const Size(100.0, 100.0); - /// // same as: new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0) + /// // same as: Rect.fromLTWH(0.0, 0.0, 100.0, 100.0) /// ``` - Rect operator &(Size other) => - Rect.fromLTWH(dx, dy, other.width, other.height); + Rect/*!*/ operator &(Size/*!*/ other) => Rect.fromLTWH(dx, dy, other.width, other.height); /// Linearly interpolate between two offsets. /// @@ -321,36 +314,30 @@ class Offset extends OffsetBase { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Offset lerp(Offset a, Offset b, double t) { + static Offset/*!*/ lerp(Offset/*?*/ a, Offset/*?*/ b, double/*!*/ t) { assert(t != null); - if (a == null && b == null) { + if (a == null && b == null) return null; - } - if (a == null) { + if (a == null) return b * t; - } - if (b == null) { + if (b == null) return a * (1.0 - t); - } return Offset(lerpDouble(a.dx, b.dx, t), lerpDouble(a.dy, b.dy, t)); } /// Compares two Offsets for equality. @override - bool operator ==(dynamic other) { - if (other is! Offset) { - return false; - } - final Offset typedOther = other; - return dx == typedOther.dx && dy == typedOther.dy; + bool/*!*/ operator ==(dynamic other) { + return other is Offset + && other.dx == dx + && other.dy == dy; } @override - int get hashCode => hashValues(dx, dy); + int/*!*/ get hashCode => hashValues(dx, dy); @override - String toString() => - 'Offset(${dx?.toStringAsFixed(1)}, ${dy?.toStringAsFixed(1)})'; + String/*!*/ toString() => 'Offset(${dx.toStringAsFixed(1)}, ${dy.toStringAsFixed(1)})'; } /// Holds a 2D floating-point size. @@ -358,25 +345,25 @@ class Offset extends OffsetBase { /// You can think of this as an [Offset] from the origin. class Size extends OffsetBase { /// Creates a [Size] with the given [width] and [height]. - const Size(double width, double height) : super(width, height); + const Size(double/*!*/ width, double/*!*/ height) : super(width, height); /// Creates an instance of [Size] that has the same values as another. // Used by the rendering library's _DebugSize hack. - Size.copy(Size source) : super(source.width, source.height); + Size.copy(Size/*!*/ source) : super(source.width, source.height); /// Creates a square [Size] whose [width] and [height] are the given dimension. /// /// See also: /// - /// * [new Size.fromRadius], which is more convenient when the available size + /// * [Size.fromRadius], which is more convenient when the available size /// is the radius of a circle. - const Size.square(double dimension) : super(dimension, dimension); + const Size.square(double/*!*/ dimension) : super(dimension, dimension); /// Creates a [Size] with the given [width] and an infinite [height]. - const Size.fromWidth(double width) : super(width, double.infinity); + const Size.fromWidth(double/*!*/ width) : super(width, double.infinity); /// Creates a [Size] with the given [height] and an infinite [width]. - const Size.fromHeight(double height) : super(double.infinity, height); + const Size.fromHeight(double/*!*/ height) : super(double.infinity, height); /// Creates a square [Size] whose [width] and [height] are twice the given /// dimension. @@ -385,14 +372,14 @@ class Size extends OffsetBase { /// /// See also: /// - /// * [new Size.square], which creates a square with the given dimension. - const Size.fromRadius(double radius) : super(radius * 2.0, radius * 2.0); + /// * [Size.square], which creates a square with the given dimension. + const Size.fromRadius(double/*!*/ radius) : super(radius * 2.0, radius * 2.0); /// The horizontal extent of this size. - double get width => _dx; + double/*!*/ get width => _dx; /// The vertical extent of this size. - double get height => _dy; + double/*!*/ get height => _dy; /// The aspect ratio of this size. /// @@ -408,16 +395,13 @@ class Size extends OffsetBase { /// ratio. /// * [FittedBox], a widget that (in most modes) attempts to maintain a /// child widget's aspect ratio while changing its size. - double get aspectRatio { - if (height != 0.0) { + double/*!*/ get aspectRatio { + if (height != 0.0) return width / height; - } - if (width > 0.0) { + if (width > 0.0) return double.infinity; - } - if (width < 0.0) { + if (width < 0.0) return double.negativeInfinity; - } return 0.0; } @@ -435,7 +419,7 @@ class Size extends OffsetBase { /// Whether this size encloses a non-zero area. /// /// Negative areas are considered empty. - bool get isEmpty => width <= 0.0 || height <= 0.0; + bool/*!*/ get isEmpty => width <= 0.0 || height <= 0.0; /// Binary subtraction operator for [Size]. /// @@ -453,13 +437,11 @@ class Size extends OffsetBase { /// right-hand-side operand, and a [height] consisting of the [height] of the /// left-hand-side operand minus the [Offset.dy] dimension of the /// right-hand-side operand. - OffsetBase operator -(OffsetBase other) { - if (other is Size) { + OffsetBase/*!*/ operator -(OffsetBase/*!*/ other) { + if (other is Size) return Offset(width - other.width, height - other.height); - } - if (other is Offset) { + if (other is Offset) return Size(width - other.dx, height - other.dy); - } throw ArgumentError(other); } @@ -470,42 +452,41 @@ class Size extends OffsetBase { /// right-hand-side operand, an [Offset], and whose [height] is the sum of the /// [height] of the left-hand-side operand and the [Offset.dy] dimension of /// the right-hand-side operand. - Size operator +(Offset other) => Size(width + other.dx, height + other.dy); + Size/*!*/ operator +(Offset/*!*/ other) => Size(width + other.dx, height + other.dy); /// Multiplication operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) multiplied by the scalar right-hand-side operand (a /// [double]). - Size operator *(double operand) => Size(width * operand, height * operand); + Size/*!*/ operator *(double/*!*/ operand) => Size(width * operand, height * operand); /// Division operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) divided by the scalar right-hand-side operand (a /// [double]). - Size operator /(double operand) => Size(width / operand, height / operand); + Size/*!*/ operator /(double/*!*/ operand) => Size(width / operand, height / operand); /// Integer (truncating) division operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) divided by the scalar right-hand-side operand (a /// [double]), rounded towards zero. - Size operator ~/(double operand) => - Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble()); + Size/*!*/ operator ~/(double/*!*/ operand) => Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns a [Size] whose dimensions are the remainder of dividing the /// left-hand-side operand (a [Size]) by the scalar right-hand-side operand (a /// [double]). - Size operator %(double operand) => Size(width % operand, height % operand); + Size/*!*/ operator %(double/*!*/ operand) => Size(width % operand, height % operand); /// The lesser of the magnitudes of the [width] and the [height]. - double get shortestSide => math.min(width.abs(), height.abs()); + double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height]. - double get longestSide => math.max(width.abs(), height.abs()); + double/*!*/ get longestSide => math.max(width.abs(), height.abs()); // Convenience methods that do the equivalent of calling the similarly named // methods on a Rect constructed from the given origin and this size. @@ -515,65 +496,60 @@ class Size extends OffsetBase { /// and this [Size]. /// /// See also [Rect.topLeft]. - Offset topLeft(Offset origin) => origin; + Offset/*!*/ topLeft(Offset/*!*/ origin) => origin; /// The offset to the center of the top edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.topCenter]. - Offset topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy); + Offset/*!*/ topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy); /// The offset to the intersection of the top and right edges of the rectangle /// described by the given offset (which is interpreted as the top-left corner) /// and this size. /// /// See also [Rect.topRight]. - Offset topRight(Offset origin) => Offset(origin.dx + width, origin.dy); + Offset/*!*/ topRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy); /// The offset to the center of the left edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.centerLeft]. - Offset centerLeft(Offset origin) => - Offset(origin.dx, origin.dy + height / 2.0); + Offset/*!*/ centerLeft(Offset/*!*/ origin) => Offset(origin.dx, origin.dy + height / 2.0); /// The offset to the point halfway between the left and right and the top and /// bottom edges of the rectangle described by the given offset (which is /// interpreted as the top-left corner) and this size. /// /// See also [Rect.center]. - Offset center(Offset origin) => - Offset(origin.dx + width / 2.0, origin.dy + height / 2.0); + Offset/*!*/ center(Offset/*!*/ origin) => Offset(origin.dx + width / 2.0, origin.dy + height / 2.0); /// The offset to the center of the right edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.centerLeft]. - Offset centerRight(Offset origin) => - Offset(origin.dx + width, origin.dy + height / 2.0); + Offset/*!*/ centerRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy + height / 2.0); /// The offset to the intersection of the bottom and left edges of the /// rectangle described by the given offset (which is interpreted as the /// top-left corner) and this size. /// /// See also [Rect.bottomLeft]. - Offset bottomLeft(Offset origin) => Offset(origin.dx, origin.dy + height); + Offset/*!*/ bottomLeft(Offset/*!*/ origin) => Offset(origin.dx, origin.dy + height); /// The offset to the center of the bottom edge of the rectangle described by /// the given offset (which is interpreted as the top-left corner) and this /// size. /// /// See also [Rect.bottomLeft]. - Offset bottomCenter(Offset origin) => - Offset(origin.dx + width / 2.0, origin.dy + height); + Offset/*!*/ bottomCenter(Offset/*!*/ origin) => Offset(origin.dx + width / 2.0, origin.dy + height); /// The offset to the intersection of the bottom and right edges of the /// rectangle described by the given offset (which is interpreted as the /// top-left corner) and this size. /// /// See also [Rect.bottomRight]. - Offset bottomRight(Offset origin) => - Offset(origin.dx + width, origin.dy + height); + Offset/*!*/ bottomRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy + height); /// Whether the point specified by the given offset (which is assumed to be /// relative to the top left of the size) lies between the left and right and @@ -581,15 +557,12 @@ class Size extends OffsetBase { /// /// Rectangles include their top and left edges but exclude their bottom and /// right edges. - bool contains(Offset offset) { - return offset.dx >= 0.0 && - offset.dx < width && - offset.dy >= 0.0 && - offset.dy < height; + bool/*!*/ contains(Offset/*!*/ offset) { + return offset.dx >= 0.0 && offset.dx < width && offset.dy >= 0.0 && offset.dy < height; } /// A [Size] with the [width] and [height] swapped. - Size get flipped => Size(height, width); + Size/*!*/ get flipped => Size(height, width); /// Linearly interpolate between two sizes /// @@ -606,38 +579,31 @@ class Size extends OffsetBase { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Size lerp(Size a, Size b, double t) { + static Size/*!*/ lerp(Size/*?*/ a, Size/*?*/ b, double/*!*/ t) { assert(t != null); - if (a == null && b == null) { + if (a == null && b == null) return null; - } - if (a == null) { + if (a == null) return b * t; - } - if (b == null) { + if (b == null) return a * (1.0 - t); - } - return Size( - lerpDouble(a.width, b.width, t), lerpDouble(a.height, b.height, t)); + return Size(lerpDouble(a.width, b.width, t), lerpDouble(a.height, b.height, t)); } /// Compares two Sizes for equality. // We don't compare the runtimeType because of _DebugSize in the framework. @override - bool operator ==(dynamic other) { - if (other is! Size) { - return false; - } - final Size typedOther = other; - return _dx == typedOther._dx && _dy == typedOther._dy; + bool/*!*/ operator ==(dynamic other) { + return other is Size + && other._dx == _dx + && other._dy == _dy; } @override - int get hashCode => hashValues(_dx, _dy); + int/*!*/ get hashCode => hashValues(_dx, _dy); @override - String toString() => - 'Size(${width?.toStringAsFixed(1)}, ${height?.toStringAsFixed(1)})'; + String/*!*/ toString() => 'Size(${width.toStringAsFixed(1)}, ${height.toStringAsFixed(1)})'; } /// An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates @@ -662,64 +628,60 @@ class Rect { /// /// To construct a [Rect] from an [Offset] and a [Size], you can use the /// rectangle constructor operator `&`. See [Offset.&]. - const Rect.fromLTWH(double left, double top, double width, double height) - : this.fromLTRB(left, top, left + width, top + height); + const Rect.fromLTWH(double/*!*/ left, double/*!*/ top, double/*!*/ width, double/*!*/ height) : this.fromLTRB(left, top, left + width, top + height); /// Construct a rectangle that bounds the given circle. /// /// The `center` argument is assumed to be an offset from the origin. - Rect.fromCircle({Offset center, double radius}) - : this.fromCenter( - center: center, - width: radius * 2, - height: radius * 2, - ); + Rect.fromCircle({ Offset/*!*/ center, double/*!*/ radius }) : this.fromCenter( + center: center, + width: radius * 2, + height: radius * 2, + ); /// Constructs a rectangle from its center point, width, and height. /// /// The `center` argument is assumed to be an offset from the origin. - Rect.fromCenter({Offset center, double width, double height}) - : this.fromLTRB( - center.dx - width / 2, - center.dy - height / 2, - center.dx + width / 2, - center.dy + height / 2, - ); + Rect.fromCenter({ Offset center/*!*/, double/*!*/ width, double/*!*/ height }) : this.fromLTRB( + center.dx - width / 2, + center.dy - height / 2, + center.dx + width / 2, + center.dy + height / 2, + ); /// Construct the smallest rectangle that encloses the given offsets, treating /// them as vectors from the origin. - Rect.fromPoints(Offset a, Offset b) - : this.fromLTRB( - math.min(a.dx, b.dx), - math.min(a.dy, b.dy), - math.max(a.dx, b.dx), - math.max(a.dy, b.dy), - ); + Rect.fromPoints(Offset/*!*/ a, Offset/*!*/ b) : this.fromLTRB( + math.min(a.dx, b.dx), + math.min(a.dy, b.dy), + math.max(a.dx, b.dx), + math.max(a.dy, b.dy), + ); /// The offset of the left edge of this rectangle from the x axis. - final double left; + final double/*!*/ left; /// The offset of the top edge of this rectangle from the y axis. - final double top; + final double/*!*/ top; /// The offset of the right edge of this rectangle from the x axis. - final double right; + final double/*!*/ right; /// The offset of the bottom edge of this rectangle from the y axis. - final double bottom; + final double/*!*/ bottom; /// The distance between the left and right edges of this rectangle. - double get width => right - left; + double/*!*/ get width => right - left; /// The distance between the top and bottom edges of this rectangle. - double get height => bottom - top; + double/*!*/ get height => bottom - top; /// The distance between the upper-left corner and the lower-right corner of /// this rectangle. - Size get size => Size(width, height); + Size/*!*/ get size => Size(width, height); /// Whether any of the dimensions are `NaN`. - bool get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN; + bool/*!*/ get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN; /// A rectangle with left, top, right, and bottom edges all at zero. static const Rect zero = Rect.fromLTRB(0.0, 0.0, 0.0, 0.0); @@ -730,33 +692,30 @@ class Rect { /// /// This covers the space from -1e9,-1e9 to 1e9,1e9. /// This is the space over which graphics operations are valid. - static const Rect largest = - Rect.fromLTRB(-_giantScalar, -_giantScalar, _giantScalar, _giantScalar); + static const Rect largest = Rect.fromLTRB(-_giantScalar, -_giantScalar, _giantScalar, _giantScalar); /// Whether any of the coordinates of this rectangle are equal to positive infinity. // included for consistency with Offset and Size - bool get isInfinite { - return left >= double.infinity || - top >= double.infinity || - right >= double.infinity || - bottom >= double.infinity; + bool/*!*/ get isInfinite { + return left >= double.infinity + || top >= double.infinity + || right >= double.infinity + || bottom >= double.infinity; } /// Whether all coordinates of this rectangle are finite. - bool get isFinite => - left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; + bool/*!*/ get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; /// Whether this rectangle encloses a non-zero area. Negative areas are /// considered empty. - bool get isEmpty => left >= right || top >= bottom; + bool/*!*/ get isEmpty => left >= right || top >= bottom; /// Returns a new rectangle translated by the given offset. /// /// To translate a rectangle by separate x and y components rather than by an /// [Offset], consider [translate]. - Rect shift(Offset offset) { - return Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.dx, - bottom + offset.dy); + Rect/*!*/ shift(Offset/*!*/ offset) { + return Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.dx, bottom + offset.dy); } /// Returns a new rectangle with translateX added to the x components and @@ -764,104 +723,104 @@ class Rect { /// /// To translate a rectangle by an [Offset] rather than by separate x and y /// components, consider [shift]. - Rect translate(double translateX, double translateY) { - return Rect.fromLTRB(left + translateX, top + translateY, - right + translateX, bottom + translateY); + Rect/*!*/ translate(double/*!*/ translateX, double/*!*/ translateY) { + return Rect.fromLTRB(left + translateX, top + translateY, right + translateX, bottom + translateY); } /// Returns a new rectangle with edges moved outwards by the given delta. - Rect inflate(double delta) { - return Rect.fromLTRB( - left - delta, top - delta, right + delta, bottom + delta); + Rect/*!*/ inflate(double/*!*/ delta) { + return Rect.fromLTRB(left - delta, top - delta, right + delta, bottom + delta); } /// Returns a new rectangle with edges moved inwards by the given delta. - Rect deflate(double delta) => inflate(-delta); + Rect/*!*/ deflate(double/*!*/ delta) => inflate(-delta); /// Returns a new rectangle that is the intersection of the given /// rectangle and this rectangle. The two rectangles must overlap /// for this to be meaningful. If the two rectangles do not overlap, /// then the resulting Rect will have a negative width or height. - Rect intersect(Rect other) { - return Rect.fromLTRB(math.max(left, other.left), math.max(top, other.top), - math.min(right, other.right), math.min(bottom, other.bottom)); + Rect/*!*/ intersect(Rect/*!*/ other) { + return Rect.fromLTRB( + math.max(left, other.left), + math.max(top, other.top), + math.min(right, other.right), + math.min(bottom, other.bottom) + ); } /// Returns a new rectangle which is the bounding box containing this /// rectangle and the given rectangle. - Rect expandToInclude(Rect other) { + Rect/*!*/ expandToInclude(Rect/*!*/ other) { return Rect.fromLTRB( - math.min(left, other.left), - math.min(top, other.top), - math.max(right, other.right), - math.max(bottom, other.bottom), + math.min(left, other.left), + math.min(top, other.top), + math.max(right, other.right), + math.max(bottom, other.bottom), ); } /// Whether `other` has a nonzero area of overlap with this rectangle. - bool overlaps(Rect other) { - if (right <= other.left || other.right <= left) { + bool/*!*/ overlaps(Rect/*!*/ other) { + if (right <= other.left || other.right <= left) return false; - } - if (bottom <= other.top || other.bottom <= top) { + if (bottom <= other.top || other.bottom <= top) return false; - } return true; } /// The lesser of the magnitudes of the [width] and the [height] of this /// rectangle. - double get shortestSide => math.min(width.abs(), height.abs()); + double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height] of this /// rectangle. - double get longestSide => math.max(width.abs(), height.abs()); + double/*!*/ get longestSide => math.max(width.abs(), height.abs()); /// The offset to the intersection of the top and left edges of this rectangle. /// /// See also [Size.topLeft]. - Offset get topLeft => Offset(left, top); + Offset/*!*/ get topLeft => Offset(left, top); /// The offset to the center of the top edge of this rectangle. /// /// See also [Size.topCenter]. - Offset get topCenter => Offset(left + width / 2.0, top); + Offset/*!*/ get topCenter => Offset(left + width / 2.0, top); /// The offset to the intersection of the top and right edges of this rectangle. /// /// See also [Size.topRight]. - Offset get topRight => Offset(right, top); + Offset/*!*/ get topRight => Offset(right, top); /// The offset to the center of the left edge of this rectangle. /// /// See also [Size.centerLeft]. - Offset get centerLeft => Offset(left, top + height / 2.0); + Offset/*!*/ get centerLeft => Offset(left, top + height / 2.0); /// The offset to the point halfway between the left and right and the top and /// bottom edges of this rectangle. /// /// See also [Size.center]. - Offset get center => Offset(left + width / 2.0, top + height / 2.0); + Offset/*!*/ get center => Offset(left + width / 2.0, top + height / 2.0); /// The offset to the center of the right edge of this rectangle. /// /// See also [Size.centerLeft]. - Offset get centerRight => Offset(right, top + height / 2.0); + Offset/*!*/ get centerRight => Offset(right, top + height / 2.0); /// The offset to the intersection of the bottom and left edges of this rectangle. /// /// See also [Size.bottomLeft]. - Offset get bottomLeft => Offset(left, bottom); + Offset/*!*/ get bottomLeft => Offset(left, bottom); /// The offset to the center of the bottom edge of this rectangle. /// /// See also [Size.bottomLeft]. - Offset get bottomCenter => Offset(left + width / 2.0, bottom); + Offset/*!*/ get bottomCenter => Offset(left + width / 2.0, bottom); /// The offset to the intersection of the bottom and right edges of this rectangle. /// /// See also [Size.bottomRight]. - Offset get bottomRight => Offset(right, bottom); + Offset/*!*/ get bottomRight => Offset(right, bottom); /// Whether the point specified by the given offset (which is assumed to be /// relative to the origin) lies between the left and right and the top and @@ -869,11 +828,8 @@ class Rect { /// /// Rectangles include their top and left edges but exclude their bottom and /// right edges. - bool contains(Offset offset) { - return offset.dx >= left && - offset.dx < right && - offset.dy >= top && - offset.dy < bottom; + bool/*!*/ contains(Offset/*!*/ offset) { + return offset.dx >= left && offset.dx < right && offset.dy >= top && offset.dy < bottom; } /// Linearly interpolate between two rectangles. @@ -891,11 +847,10 @@ class Rect { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Rect lerp(Rect a, Rect b, double t) { + static Rect/*!*/ lerp(Rect/*?*/ a, Rect/*?*/ b, double/*!*/ t) { assert(t != null); - if (a == null && b == null) { + if (a == null && b == null) return null; - } if (a == null) return Rect.fromLTRB(b.left * t, b.top * t, b.right * t, b.bottom * t); if (b == null) { @@ -911,41 +866,38 @@ class Rect { } @override - bool operator ==(dynamic other) { - if (identical(this, other)) { + bool/*!*/ operator ==(dynamic other) { + if (identical(this, other)) return true; - } - if (runtimeType != other.runtimeType) { + if (runtimeType != other.runtimeType) return false; - } - final Rect typedOther = other; - return left == typedOther.left && - top == typedOther.top && - right == typedOther.right && - bottom == typedOther.bottom; + return other is Rect + && other.left == left + && other.top == top + && other.right == right + && other.bottom == bottom; } @override - int get hashCode => hashValues(left, top, right, bottom); + int/*!*/ get hashCode => hashValues(left, top, right, bottom); @override - String toString() => - 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})'; + String/*!*/ toString() => 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})'; } /// A radius for either circular or elliptical shapes. class Radius { /// Constructs a circular radius. [x] and [y] will have the same radius value. - const Radius.circular(double radius) : this.elliptical(radius, radius); + const Radius.circular(double/*!*/ radius) : this.elliptical(radius, radius); /// Constructs an elliptical radius with the given radii. const Radius.elliptical(this.x, this.y); /// The radius value on the horizontal axis. - final double x; + final double/*!*/ x; /// The radius value on the vertical axis. - final double y; + final double/*!*/ y; /// A radius with [x] and [y] values set to zero. /// @@ -960,55 +912,49 @@ class Radius { /// occur as part of expressions. For example, negating a radius of one pixel /// and then adding the result to another radius is equivalent to subtracting /// a radius of one pixel from the other. - Radius operator -() => Radius.elliptical(-x, -y); + Radius/*!*/ operator -() => Radius.elliptical(-x, -y); /// Binary subtraction operator. /// /// Returns a radius whose [x] value is the left-hand-side operand's [x] /// minus the right-hand-side operand's [x] and whose [y] value is the /// left-hand-side operand's [y] minus the right-hand-side operand's [y]. - Radius operator -(Radius other) => - Radius.elliptical(x - other.x, y - other.y); + Radius/*!*/ operator -(Radius/*!*/ other) => Radius.elliptical(x - other.x, y - other.y); /// Binary addition operator. /// /// Returns a radius whose [x] value is the sum of the [x] values of the /// two operands, and whose [y] value is the sum of the [y] values of the /// two operands. - Radius operator +(Radius other) => - Radius.elliptical(x + other.x, y + other.y); + Radius/*!*/ operator +(Radius/*!*/ other) => Radius.elliptical(x + other.x, y + other.y); /// Multiplication operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) multiplied by the scalar /// right-hand-side operand (a double). - Radius operator *(double operand) => - Radius.elliptical(x * operand, y * operand); + Radius/*!*/ operator *(double/*!*/ operand) => Radius.elliptical(x * operand, y * operand); /// Division operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) divided by the scalar right-hand-side /// operand (a double). - Radius operator /(double operand) => - Radius.elliptical(x / operand, y / operand); + Radius/*!*/ operator /(double/*!*/ operand) => Radius.elliptical(x / operand, y / operand); /// Integer (truncating) division operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) divided by the scalar right-hand-side /// operand (a double), rounded towards zero. - Radius operator ~/(double operand) => - Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); + Radius/*!*/ operator ~/(double/*!*/ operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns a radius whose coordinates are the remainder of dividing the /// coordinates of the left-hand-side operand (a radius) by the scalar /// right-hand-side operand (a double). - Radius operator %(double operand) => - Radius.elliptical(x % operand, y % operand); + Radius/*!*/ operator %(double/*!*/ operand) => Radius.elliptical(x % operand, y % operand); /// Linearly interpolate between two radii. /// @@ -1025,14 +971,12 @@ class Radius { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Radius lerp(Radius a, Radius b, double t) { + static Radius/*!*/ lerp(Radius/*?*/ a, Radius/*?*/ b, double/*!*/ t) { assert(t != null); - if (a == null && b == null) { + if (a == null && b == null) return null; - } - if (a == null) { + if (a == null) return Radius.elliptical(b.x * t, b.y * t); - } if (b == null) { final double k = 1.0 - t; return Radius.elliptical(a.x * k, a.y * k); @@ -1044,26 +988,25 @@ class Radius { } @override - bool operator ==(dynamic other) { - if (identical(this, other)) { + bool/*!*/ operator ==(dynamic other) { + if (identical(this, other)) return true; - } - if (runtimeType != other.runtimeType) { + if (runtimeType != other.runtimeType) return false; - } - final Radius typedOther = other; - return typedOther.x == x && typedOther.y == y; + + return other is Radius + && other.x == x + && other.y == y; } @override - int get hashCode => hashValues(x, y); + int/*!*/ get hashCode => hashValues(x, y); @override - String toString() { - return x == y - ? 'Radius.circular(${x.toStringAsFixed(1)})' - : 'Radius.elliptical(${x.toStringAsFixed(1)}, ' - '${y.toStringAsFixed(1)})'; + String/*!*/ toString() { + return x == y ? 'Radius.circular(${x.toStringAsFixed(1)})' : + 'Radius.elliptical(${x.toStringAsFixed(1)}, ' + '${y.toStringAsFixed(1)})'; } } @@ -1071,95 +1014,94 @@ class Radius { class RRect { /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and the same radii along its horizontal axis and its vertical axis. - const RRect.fromLTRBXY(double left, double top, double right, double bottom, - double radiusX, double radiusY) - : this._raw( - top: top, - left: left, - right: right, - bottom: bottom, - tlRadiusX: radiusX, - tlRadiusY: radiusY, - trRadiusX: radiusX, - trRadiusY: radiusY, - blRadiusX: radiusX, - blRadiusY: radiusY, - brRadiusX: radiusX, - brRadiusY: radiusY, - uniformRadii: radiusX == radiusY, - ); + const RRect.fromLTRBXY(double/*!*/ left, double/*!*/ top, double/*!*/ right, double/*!*/ bottom, + double/*!*/ radiusX, double/*!*/ radiusY) : this._raw( + top: top, + left: left, + right: right, + bottom: bottom, + tlRadiusX: radiusX, + tlRadiusY: radiusY, + trRadiusX: radiusX, + trRadiusY: radiusY, + blRadiusX: radiusX, + blRadiusY: radiusY, + brRadiusX: radiusX, + brRadiusY: radiusY, + uniformRadii: radiusX == radiusY, + ); /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and the same radius in each corner. - RRect.fromLTRBR( - double left, double top, double right, double bottom, Radius radius) - : this._raw( - top: top, - left: left, - right: right, - bottom: bottom, - tlRadiusX: radius.x, - tlRadiusY: radius.y, - trRadiusX: radius.x, - trRadiusY: radius.y, - blRadiusX: radius.x, - blRadiusY: radius.y, - brRadiusX: radius.x, - brRadiusY: radius.y, - uniformRadii: radius.x == radius.y, - ); + RRect.fromLTRBR(double/*!*/ left, double/*!*/ top, double/*!*/ right, double/*!*/ bottom, + Radius/*!*/ radius) + : this._raw( + top: top, + left: left, + right: right, + bottom: bottom, + tlRadiusX: radius.x, + tlRadiusY: radius.y, + trRadiusX: radius.x, + trRadiusY: radius.y, + blRadiusX: radius.x, + blRadiusY: radius.y, + brRadiusX: radius.x, + brRadiusY: radius.y, + uniformRadii: radius.x == radius.y, + ); /// Construct a rounded rectangle from its bounding box and the same radii /// along its horizontal axis and its vertical axis. - RRect.fromRectXY(Rect rect, double radiusX, double radiusY) - : this._raw( - top: rect.top, - left: rect.left, - right: rect.right, - bottom: rect.bottom, - tlRadiusX: radiusX, - tlRadiusY: radiusY, - trRadiusX: radiusX, - trRadiusY: radiusY, - blRadiusX: radiusX, - blRadiusY: radiusY, - brRadiusX: radiusX, - brRadiusY: radiusY, - uniformRadii: radiusX == radiusY, - ); + RRect.fromRectXY(Rect/*!*/ rect, double/*!*/ radiusX, double/*!*/ radiusY) + : this._raw( + top: rect.top, + left: rect.left, + right: rect.right, + bottom: rect.bottom, + tlRadiusX: radiusX, + tlRadiusY: radiusY, + trRadiusX: radiusX, + trRadiusY: radiusY, + blRadiusX: radiusX, + blRadiusY: radiusY, + brRadiusX: radiusX, + brRadiusY: radiusY, + uniformRadii: radiusX == radiusY, + ); /// Construct a rounded rectangle from its bounding box and a radius that is /// the same in each corner. - RRect.fromRectAndRadius(Rect rect, Radius radius) - : this._raw( - top: rect.top, - left: rect.left, - right: rect.right, - bottom: rect.bottom, - tlRadiusX: radius.x, - tlRadiusY: radius.y, - trRadiusX: radius.x, - trRadiusY: radius.y, - blRadiusX: radius.x, - blRadiusY: radius.y, - brRadiusX: radius.x, - brRadiusY: radius.y, - uniformRadii: radius.x == radius.y, - ); + RRect.fromRectAndRadius(Rect/*!*/ rect, Radius/*!*/ radius) + : this._raw( + top: rect.top, + left: rect.left, + right: rect.right, + bottom: rect.bottom, + tlRadiusX: radius.x, + tlRadiusY: radius.y, + trRadiusX: radius.x, + trRadiusY: radius.y, + blRadiusX: radius.x, + blRadiusY: radius.y, + brRadiusX: radius.x, + brRadiusY: radius.y, + uniformRadii: radius.x == radius.y, + ); /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and topLeft, topRight, bottomRight, and bottomLeft radii. /// /// The corner radii default to [Radius.zero], i.e. right-angled corners. RRect.fromLTRBAndCorners( - double left, - double top, - double right, - double bottom, { - Radius topLeft = Radius.zero, - Radius topRight = Radius.zero, - Radius bottomRight = Radius.zero, - Radius bottomLeft = Radius.zero, + double/*!*/ left, + double/*!*/ top, + double/*!*/ right, + double/*!*/ bottom, { + Radius/*!*/ topLeft = Radius.zero, + Radius/*!*/ topRight = Radius.zero, + Radius/*!*/ bottomRight = Radius.zero, + Radius/*!*/ bottomLeft = Radius.zero, }) : this._raw( top: top, left: left, @@ -1186,12 +1128,15 @@ class RRect { /// topRight, bottomRight, and bottomLeft radii. /// /// The corner radii default to [Radius.zero], i.e. right-angled corners - RRect.fromRectAndCorners(Rect rect, - {Radius topLeft = Radius.zero, - Radius topRight = Radius.zero, - Radius bottomRight = Radius.zero, - Radius bottomLeft = Radius.zero}) - : this._raw( + RRect.fromRectAndCorners( + Rect/*!*/ rect, + { + Radius/*!*/ topLeft = Radius.zero, + Radius/*!*/ topRight = Radius.zero, + Radius/*!*/ bottomRight = Radius.zero, + Radius/*!*/ bottomLeft = Radius.zero + } + ) : this._raw( top: rect.top, left: rect.left, right: rect.right, @@ -1242,62 +1187,62 @@ class RRect { this.webOnlyUniformRadii = uniformRadii; /// The offset of the left edge of this rectangle from the x axis. - final double left; + final double/*!*/ left; /// The offset of the top edge of this rectangle from the y axis. - final double top; + final double/*!*/ top; /// The offset of the right edge of this rectangle from the x axis. - final double right; + final double/*!*/ right; /// The offset of the bottom edge of this rectangle from the y axis. - final double bottom; + final double/*!*/ bottom; /// The top-left horizontal radius. - final double tlRadiusX; + final double/*!*/ tlRadiusX; /// The top-left vertical radius. - final double tlRadiusY; + final double/*!*/ tlRadiusY; /// The top-left [Radius]. - Radius get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY); + Radius/*!*/ get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY); /// The top-right horizontal radius. - final double trRadiusX; + final double/*!*/ trRadiusX; /// The top-right vertical radius. - final double trRadiusY; + final double/*!*/ trRadiusY; /// The top-right [Radius]. - Radius get trRadius => Radius.elliptical(trRadiusX, trRadiusY); + Radius/*!*/ get trRadius => Radius.elliptical(trRadiusX, trRadiusY); /// The bottom-right horizontal radius. - final double brRadiusX; + final double/*!*/ brRadiusX; /// The bottom-right vertical radius. - final double brRadiusY; + final double/*!*/ brRadiusY; /// The bottom-right [Radius]. - Radius get brRadius => Radius.elliptical(brRadiusX, brRadiusY); + Radius/*!*/ get brRadius => Radius.elliptical(brRadiusX, brRadiusY); /// The bottom-left horizontal radius. - final double blRadiusX; + final double/*!*/ blRadiusX; /// The bottom-left vertical radius. - final double blRadiusY; + final double/*!*/ blRadiusY; /// If radii is equal for all corners. // webOnly - final bool webOnlyUniformRadii; + final bool/*!*/ webOnlyUniformRadii; /// The bottom-left [Radius]. - Radius get blRadius => Radius.elliptical(blRadiusX, blRadiusY); + Radius/*!*/ get blRadius => Radius.elliptical(blRadiusX, blRadiusY); /// A rounded rectangle with all the values set to zero. static const RRect zero = RRect._raw(); /// Returns a new [RRect] translated by the given offset. - RRect shift(Offset offset) { + RRect/*!*/ shift(Offset/*!*/ offset) { return RRect._raw( left: left + offset.dx, top: top + offset.dy, @@ -1316,7 +1261,7 @@ class RRect { /// Returns a new [RRect] with edges and radii moved outwards by the given /// delta. - RRect inflate(double delta) { + RRect/*!*/ inflate(double/*!*/ delta) { return RRect._raw( left: left - delta, top: top - delta, @@ -1334,22 +1279,22 @@ class RRect { } /// Returns a new [RRect] with edges and radii moved inwards by the given delta. - RRect deflate(double delta) => inflate(-delta); + RRect/*!*/ deflate(double/*!*/ delta) => inflate(-delta); /// The distance between the left and right edges of this rectangle. - double get width => right - left; + double/*!*/ get width => right - left; /// The distance between the top and bottom edges of this rectangle. - double get height => bottom - top; + double/*!*/ get height => bottom - top; /// The bounding box of this rounded rectangle (the rectangle with no rounded corners). - Rect get outerRect => Rect.fromLTRB(left, top, right, bottom); + Rect/*!*/ get outerRect => Rect.fromLTRB(left, top, right, bottom); /// The non-rounded rectangle that is constrained by the smaller of the two /// diagonals, with each diagonal traveling through the middle of the curve /// corners. The middle of a corner is the intersection of the curve with its /// respective quadrant bisector. - Rect get safeInnerRect { + Rect/*!*/ get safeInnerRect { const double kInsetFactor = 0.29289321881; // 1-cos(pi/4) final double leftRadius = math.max(blRadiusX, tlRadiusX); @@ -1358,10 +1303,11 @@ class RRect { final double bottomRadius = math.max(brRadiusY, blRadiusY); return Rect.fromLTRB( - left + leftRadius * kInsetFactor, - top + topRadius * kInsetFactor, - right - rightRadius * kInsetFactor, - bottom - bottomRadius * kInsetFactor); + left + leftRadius * kInsetFactor, + top + topRadius * kInsetFactor, + right - rightRadius * kInsetFactor, + bottom - bottomRadius * kInsetFactor + ); } /// The rectangle that would be formed using the axis-aligned intersection of @@ -1370,115 +1316,121 @@ class RRect { /// intersection of the [wideMiddleRect] and the [tallMiddleRect]. If any of /// the intersections are void, the resulting [Rect] will have negative width /// or height. - Rect get middleRect { + Rect/*!*/ get middleRect { final double leftRadius = math.max(blRadiusX, tlRadiusX); final double topRadius = math.max(tlRadiusY, trRadiusY); final double rightRadius = math.max(trRadiusX, brRadiusX); final double bottomRadius = math.max(brRadiusY, blRadiusY); - return Rect.fromLTRB(left + leftRadius, top + topRadius, - right - rightRadius, bottom - bottomRadius); + return Rect.fromLTRB( + left + leftRadius, + top + topRadius, + right - rightRadius, + bottom - bottomRadius + ); } /// The biggest rectangle that is entirely inside the rounded rectangle and /// has the full width of the rounded rectangle. If the rounded rectangle does /// not have an axis-aligned intersection of its left and right side, the /// resulting [Rect] will have negative width or height. - Rect get wideMiddleRect { + Rect/*!*/ get wideMiddleRect { final double topRadius = math.max(tlRadiusY, trRadiusY); final double bottomRadius = math.max(brRadiusY, blRadiusY); - return Rect.fromLTRB(left, top + topRadius, right, bottom - bottomRadius); + return Rect.fromLTRB( + left, + top + topRadius, + right, + bottom - bottomRadius + ); } /// The biggest rectangle that is entirely inside the rounded rectangle and /// has the full height of the rounded rectangle. If the rounded rectangle /// does not have an axis-aligned intersection of its top and bottom side, the /// resulting [Rect] will have negative width or height. - Rect get tallMiddleRect { + Rect/*!*/ get tallMiddleRect { final double leftRadius = math.max(blRadiusX, tlRadiusX); final double rightRadius = math.max(trRadiusX, brRadiusX); - return Rect.fromLTRB(left + leftRadius, top, right - rightRadius, bottom); + return Rect.fromLTRB( + left + leftRadius, + top, + right - rightRadius, + bottom + ); } /// Whether this rounded rectangle encloses a non-zero area. /// Negative areas are considered empty. - bool get isEmpty => left >= right || top >= bottom; + bool/*!*/ get isEmpty => left >= right || top >= bottom; /// Whether all coordinates of this rounded rectangle are finite. - bool get isFinite => - left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; + bool/*!*/ get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; /// Whether this rounded rectangle is a simple rectangle with zero /// corner radii. - bool get isRect { + bool/*!*/ get isRect { return (tlRadiusX == 0.0 || tlRadiusY == 0.0) && - (trRadiusX == 0.0 || trRadiusY == 0.0) && - (blRadiusX == 0.0 || blRadiusY == 0.0) && - (brRadiusX == 0.0 || brRadiusY == 0.0); + (trRadiusX == 0.0 || trRadiusY == 0.0) && + (blRadiusX == 0.0 || blRadiusY == 0.0) && + (brRadiusX == 0.0 || brRadiusY == 0.0); } /// Whether this rounded rectangle has a side with no straight section. - bool get isStadium { - return tlRadius == trRadius && - trRadius == brRadius && - brRadius == blRadius && - (width <= 2.0 * tlRadiusX || height <= 2.0 * tlRadiusY); + bool/*!*/ get isStadium { + return tlRadius == trRadius + && trRadius == brRadius + && brRadius == blRadius + && (width <= 2.0 * tlRadiusX || height <= 2.0 * tlRadiusY); } /// Whether this rounded rectangle has no side with a straight section. - bool get isEllipse { - return tlRadius == trRadius && - trRadius == brRadius && - brRadius == blRadius && - width <= 2.0 * tlRadiusX && - height <= 2.0 * tlRadiusY; + bool/*!*/ get isEllipse { + return tlRadius == trRadius + && trRadius == brRadius + && brRadius == blRadius + && width <= 2.0 * tlRadiusX + && height <= 2.0 * tlRadiusY; } /// Whether this rounded rectangle would draw as a circle. - bool get isCircle => width == height && isEllipse; + bool/*!*/ get isCircle => width == height && isEllipse; /// The lesser of the magnitudes of the [width] and the [height] of this /// rounded rectangle. - double get shortestSide => math.min(width.abs(), height.abs()); + double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height] of this /// rounded rectangle. - double get longestSide => math.max(width.abs(), height.abs()); + double/*!*/ get longestSide => math.max(width.abs(), height.abs()); /// Whether any of the dimensions are `NaN`. - bool get hasNaN => - left.isNaN || - top.isNaN || - right.isNaN || - bottom.isNaN || - trRadiusX.isNaN || - trRadiusY.isNaN || - tlRadiusX.isNaN || - tlRadiusY.isNaN || - brRadiusX.isNaN || - brRadiusY.isNaN || - blRadiusX.isNaN || - blRadiusY.isNaN; + bool/*!*/ get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN || + trRadiusX.isNaN || trRadiusY.isNaN || tlRadiusX.isNaN || tlRadiusY.isNaN || + brRadiusX.isNaN || brRadiusY.isNaN || blRadiusX.isNaN || blRadiusY.isNaN; /// The offset to the point halfway between the left and right and the top and /// bottom edges of this rectangle. - Offset get center => Offset(left + width / 2.0, top + height / 2.0); + Offset/*!*/ get center => Offset(left + width / 2.0, top + height / 2.0); // Returns the minimum between min and scale to which radius1 and radius2 // should be scaled with in order not to exceed the limit. double _getMin(double min, double radius1, double radius2, double limit) { final double sum = radius1 + radius2; - if (sum > limit && sum != 0.0) { + if (sum > limit && sum != 0.0) return math.min(min, limit / sum); - } return min; } - // Scales all radii so that on each side their sum will not pass the size of - // the width/height. - // - // Inspired from: - // https://github.com/google/skia/blob/master/src/core/SkRRect.cpp#L164 - RRect scaleRadii() { + /// Scales all radii so that on each side their sum will not exceed the size + /// of the width/height. + /// + /// Skia already handles RRects with radii that are too large in this way. + /// Therefore, this method is only needed for RRect use cases that require + /// the appropriately scaled radii values. + /// + /// See the [Skia scaling implementation](https://github.com/google/skia/blob/master/src/core/SkRRect.cpp) + /// for more details. + RRect/*!*/ scaleRadii() { double scale = 1.0; scale = _getMin(scale, blRadiusY, tlRadiusY, height); scale = _getMin(scale, tlRadiusX, trRadiusX, width); @@ -1525,13 +1477,9 @@ class RRect { /// radii the first time it is called on a particular [RRect] instance. When /// using this method, prefer to reuse existing [RRect]s rather than /// recreating the object each time. - bool contains(Offset point) { - if (point.dx < left || - point.dx >= right || - point.dy < top || - point.dy >= bottom) { + bool/*!*/ contains(Offset/*!*/ point) { + if (point.dx < left || point.dx >= right || point.dy < top || point.dy >= bottom) return false; // outside bounding box - } final RRect scaled = scaleRadii(); @@ -1548,19 +1496,19 @@ class RRect { radiusX = scaled.tlRadiusX; radiusY = scaled.tlRadiusY; } else if (point.dx > right - scaled.trRadiusX && - point.dy < top + scaled.trRadiusY) { + point.dy < top + scaled.trRadiusY) { x = point.dx - right + scaled.trRadiusX; y = point.dy - top - scaled.trRadiusY; radiusX = scaled.trRadiusX; radiusY = scaled.trRadiusY; } else if (point.dx > right - scaled.brRadiusX && - point.dy > bottom - scaled.brRadiusY) { + point.dy > bottom - scaled.brRadiusY) { x = point.dx - right + scaled.brRadiusX; y = point.dy - bottom + scaled.brRadiusY; radiusX = scaled.brRadiusX; radiusY = scaled.brRadiusY; } else if (point.dx < left + scaled.blRadiusX && - point.dy > bottom - scaled.blRadiusY) { + point.dy > bottom - scaled.blRadiusY) { x = point.dx - left - scaled.blRadiusX; y = point.dy - bottom + scaled.blRadiusY; radiusX = scaled.blRadiusX; @@ -1572,9 +1520,8 @@ class RRect { x = x / radiusX; y = y / radiusY; // check if the point is outside the unit circle - if (x * x + y * y > 1.0) { + if (x * x + y * y > 1.0) return false; - } return true; } @@ -1593,11 +1540,10 @@ class RRect { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static RRect lerp(RRect a, RRect b, double t) { + static RRect/*!*/ lerp(RRect/*?*/ a, RRect/*?*/ b, double/*!*/ t) { assert(t != null); - if (a == null && b == null) { + if (a == null && b == null) return null; - } if (a == null) { return RRect._raw( left: b.left * t, @@ -1648,50 +1594,51 @@ class RRect { } @override - bool operator ==(dynamic other) { - if (identical(this, other)) { + bool/*!*/ operator ==(dynamic other) { + if (identical(this, other)) return true; - } - if (runtimeType != other.runtimeType) { + if (runtimeType != other.runtimeType) return false; - } - final RRect typedOther = other; - return left == typedOther.left && - top == typedOther.top && - right == typedOther.right && - bottom == typedOther.bottom && - tlRadiusX == typedOther.tlRadiusX && - tlRadiusY == typedOther.tlRadiusY && - trRadiusX == typedOther.trRadiusX && - trRadiusY == typedOther.trRadiusY && - blRadiusX == typedOther.blRadiusX && - blRadiusY == typedOther.blRadiusY && - brRadiusX == typedOther.brRadiusX && - brRadiusY == typedOther.brRadiusY; + return other is RRect + && other.left == left + && other.top == top + && other.right == right + && other.bottom == bottom + && other.tlRadiusX == tlRadiusX + && other.tlRadiusY == tlRadiusY + && other.trRadiusX == trRadiusX + && other.trRadiusY == trRadiusY + && other.blRadiusX == blRadiusX + && other.blRadiusY == blRadiusY + && other.brRadiusX == brRadiusX + && other.brRadiusY == brRadiusY; } @override - int get hashCode => hashValues(left, top, right, bottom, tlRadiusX, tlRadiusY, - trRadiusX, trRadiusY, blRadiusX, blRadiusY, brRadiusX, brRadiusY); + int/*!*/ get hashCode => hashValues(left, top, right, bottom, + tlRadiusX, tlRadiusY, trRadiusX, trRadiusY, + blRadiusX, blRadiusY, brRadiusX, brRadiusY); @override - String toString() { + String/*!*/ toString() { final String rect = '${left.toStringAsFixed(1)}, ' - '${top.toStringAsFixed(1)}, ' - '${right.toStringAsFixed(1)}, ' - '${bottom.toStringAsFixed(1)}'; - if (tlRadius == trRadius && trRadius == brRadius && brRadius == blRadius) { + '${top.toStringAsFixed(1)}, ' + '${right.toStringAsFixed(1)}, ' + '${bottom.toStringAsFixed(1)}'; + if (tlRadius == trRadius && + trRadius == brRadius && + brRadius == blRadius) { if (tlRadius.x == tlRadius.y) return 'RRect.fromLTRBR($rect, ${tlRadius.x.toStringAsFixed(1)})'; return 'RRect.fromLTRBXY($rect, ${tlRadius.x.toStringAsFixed(1)}, ${tlRadius.y.toStringAsFixed(1)})'; } return 'RRect.fromLTRBAndCorners(' - '$rect, ' - 'topLeft: $tlRadius, ' - 'topRight: $trRadius, ' - 'bottomRight: $brRadius, ' - 'bottomLeft: $blRadius' - ')'; + '$rect, ' + 'topLeft: $tlRadius, ' + 'topRight: $trRadius, ' + 'bottomRight: $brRadius, ' + 'bottomLeft: $blRadius' + ')'; } } @@ -1720,12 +1667,12 @@ class RSTransform { /// argument multiplied by the x-coordinate of the rotation point, minus the /// `scos` argument multiplied by the y-coordinate of the rotation point. /// - /// The [new RSTransform.fromComponents] method may be a simpler way to + /// The [RSTransform.fromComponents] method may be a simpler way to /// construct these values. However, if there is a way to factor out the /// computations of the sine and cosine of the rotation so that they can be /// reused over multiple calls to this constructor, it may be more efficient /// to directly use this constructor instead. - RSTransform(double scos, double ssin, double tx, double ty) { + RSTransform(double/*!*/ scos, double/*!*/ ssin, double/*!*/ tx, double/*!*/ ty) { _value ..[0] = scos ..[1] = ssin @@ -1752,13 +1699,14 @@ class RSTransform { /// (which are computed each time this constructor is called) and reuse them /// over multiple [RSTransform] objects, it may be more efficient to directly /// use the more direct [new RSTransform] constructor instead. - factory RSTransform.fromComponents( - {double rotation, - double scale, - double anchorX, - double anchorY, - double translateX, - double translateY}) { + factory RSTransform.fromComponents({ + double/*!*/ rotation, + double/*!*/ scale, + double/*!*/ anchorX, + double/*!*/ anchorY, + double/*!*/ translateX, + double/*!*/ translateY + }) { final double scos = math.cos(rotation) * scale; final double ssin = math.sin(rotation) * scale; final double tx = translateX + -scos * anchorX + ssin * anchorY; @@ -1769,74 +1717,18 @@ class RSTransform { final Float32List _value = Float32List(4); /// The cosine of the rotation multiplied by the scale factor. - double get scos => _value[0]; + double/*!*/ get scos => _value[0]; /// The sine of the rotation multiplied by that same scale factor. - double get ssin => _value[1]; + double/*!*/ get ssin => _value[1]; /// The x coordinate of the translation, minus [scos] multiplied by the /// x-coordinate of the rotation point, plus [ssin] multiplied by the /// y-coordinate of the rotation point. - double get tx => _value[2]; + double/*!*/ get tx => _value[2]; /// The y coordinate of the translation, minus [ssin] multiplied by the /// x-coordinate of the rotation point, minus [scos] multiplied by the /// y-coordinate of the rotation point. - double get ty => _value[3]; -} - -/// Holds 2 floating-point coordinates. -class Point { - const Point(this.x, this.y); - - final double x; - final double y; - - static const Point origin = Point(0.0, 0.0); - - Point operator -() => Point(-x, -y); - Offset operator -(Point other) => Offset(x - other.x, y - other.y); - Point operator +(Offset other) => Point(x + other.dx, y + other.dy); - Rect operator &(Size other) => Rect.fromLTWH(x, y, other.width, other.height); - - Point operator *(double operand) => Point(x * operand, y * operand); - Point operator /(double operand) => Point(x / operand, y / operand); - Point operator ~/(double operand) => - Point((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); - Point operator %(double operand) => Point(x % operand, y % operand); - - // does the equivalent of "return this - Point.origin" - Offset toOffset() => Offset(x, y); - - /// Linearly interpolate between two points - /// - /// If either point is null, this function interpolates from [Point.origin]. - static Point lerp(Point a, Point b, double t) { - if (a == null && b == null) { - return null; - } - if (a == null) { - return b * t; - } - if (b == null) { - return a * (1.0 - t); - } - return Point(lerpDouble(a.x, b.x, t), lerpDouble(a.y, b.y, t)); - } - - @override - bool operator ==(dynamic other) { - if (other is! Point) { - return false; - } - final Point typedOther = other; - return x == typedOther.x && y == typedOther.y; - } - - @override - int get hashCode => hashValues(x, y); - - @override - String toString() => - 'Point(${x?.toStringAsFixed(1)}, ${y?.toStringAsFixed(1)})'; + double/*!*/ get ty => _value[3]; }