Dimension class
The dimension of a rectangular area given by a width and a height.
class Dimension {
/// the width
final num width;
/// the height
final num height;
/**
* Creates a dimension object with [width] and [height].
*
* Throws [ArgumentError] if either [width] or [height] is
* negative.
*/
Dimension(this.width, this.height) {
_require(width >=0, "width must be positive");
_require(height >=0, "height must be positive");
}
bool operator ==(other) => width == other.width && height == other.height;
@override int get hashCode => width.hashCode * 31 + height.hashCode;
@override String toString() => "{Dimension: width=$width, height=$height}";
Dimension operator *(num factor) =>
new Dimension(width * factor, height * factor);
Dimension operator /(num divisor) =>
new Dimension(width / divisor, height / divisor);
Dimension toInt() => new Dimension(width.toInt(), height.toInt());
}
Constructors
Properties
final int hashCode #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.
docs inherited from Object
@override int get hashCode => width.hashCode * 31 + height.hashCode;
Operators
Dimension operator *(num factor) #
Dimension operator *(num factor) => new Dimension(width * factor, height * factor);
Dimension operator /(num divisor) #
Dimension operator /(num divisor) => new Dimension(width / divisor, height / divisor);
bool operator ==(other) #
The equality operator.
The default behavior for all Objects is to return true if and
only if this and
other are the same object.
If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.
docs inherited from Object
bool operator ==(other) => width == other.width && height == other.height;