aspectRatio property
The aspect ratio of this size.
This returns the width divided by the height.
If the width is zero, the result will be zero. If the height is zero (and the width is not), the result will be double.infinity or double.negativeInfinity as determined by the sign of width.
See also:
- AspectRatio, a widget for giving a child widget a specific aspect ratio.
- FittedBox, a widget that (in most modes) attempts to maintain a child widget's aspect ratio while changing its size.
Implementation
double get aspectRatio {
if (height != 0.0) {
return width / height;
}
if (width > 0.0) {
return double.infinity;
}
if (width < 0.0) {
return double.negativeInfinity;
}
return 0.0;
}