AspectRatio class

The aspect-ratio CSS property allows you to define the desired width-to-height ratio of an element's box. This means that even if the parent container or viewport size changes, the browser will adjust the element's dimensions to maintain the specified width-to-height ratio.

Read more: MDN aspect-ratio

Constructors

AspectRatio(int num, [int? denom])
Create an aspect ratio from the given numerator and optional denominator. The property is defined as num / denom. If denom is omitted, it is assumed to be 1.
const
factory
AspectRatio.autoOrRatio(int num, [int? denom])
Create an aspect ratio where auto auto is used if the element is a replaced element with a natural aspect ratio, like an element. Otherwise, the specified ratio of num / denom is used as the preferred aspect ratio.
const
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String
The css value
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

auto → const AspectRatio
Replaced elements with an intrinsic aspect ratio use that aspect ratio, otherwise the box has no preferred aspect ratio. Size calculations involving intrinsic aspect ratio always work with the content box dimensions.
inherit → const AspectRatio
initial → const AspectRatio
revert → const AspectRatio
revertLayer → const AspectRatio
unset → const AspectRatio