aspectRatio property

double get aspectRatio

Returns size.width / size.height.

Will return 1.0 if:

  • isInitialized is false
  • size.width, or size.height is equal to 0.0
  • aspect ratio would be less than or equal to 0.0

Implementation

double get aspectRatio {
  if (!isInitialized || size.width == 0 || size.height == 0) {
    return 1.0;
  }
  final double aspectRatio = size.width / size.height;
  if (aspectRatio <= 0) {
    return 1.0;
  }
  return aspectRatio;
}