Alignment class

A point within a rectangle.

Alignment(0.0, 0.0) represents the center of the rectangle. The distance from -1.0 to +1.0 is the distance from one side of the rectangle to the other side of the rectangle. Therefore, 2.0 units horizontally (or vertically) is equivalent to the width (or height) of the rectangle.

Alignment(-1.0, -1.0) represents the top left of the rectangle.

Alignment(1.0, 1.0) represents the bottom right of the rectangle.

Alignment(0.0, 3.0) represents a point that is horizontally centered with respect to the rectangle and vertically below the bottom of the rectangle by the height of the rectangle.

Alignment(0.0, -0.5) represents a point that is horizontally centered with respect to the rectangle and vertically half way between the top edge and the center.

Alignment(x, y) in a rectangle with height h and width w describes the point (x * w/2 + w/2, y * h/2 + h/2) in the coordinate system of the rectangle.

Alignment uses visual coordinates, which means increasing x moves the point from left to right. To support layouts with a right-to-left TextDirection, consider using AlignmentDirectional, in which the direction the point moves when increasing the horizontal value depends on the TextDirection.

A variety of widgets use Alignment in their configuration, most notably:

See also:

Inheritance
Implementers

Constructors

Alignment(double x, double y)
Creates an alignment.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
x double
The distance fraction in the horizontal direction.
final
y double
The distance fraction in the vertical direction.
final

Methods

add(AlignmentGeometry other) AlignmentGeometry
Returns the sum of two AlignmentGeometry objects.
override
alongOffset(Offset other) Offset
Returns the offset that is this fraction in the direction of the given offset.
alongSize(Size other) Offset
Returns the offset that is this fraction within the given size.
inscribe(Size size, Rect rect) Rect
Returns a rect of the given size, aligned within given rect as specified by this alignment.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(TextDirection? direction) Alignment
Convert this instance into an Alignment, which uses literal coordinates (the x coordinate being explicitly a distance from the left).
override
toString() String
A string representation of this object.
override
withinRect(Rect rect) Offset
Returns the point that is this fraction within the given rect.

Operators

operator %(double other) Alignment
Computes the remainder in each dimension by the given factor.
override
operator *(double other) Alignment
Scales the Alignment in each dimension by the given factor.
override
operator +(Alignment other) Alignment
Returns the sum of two Alignments.
operator -(Alignment other) Alignment
Returns the difference between two Alignments.
operator /(double other) Alignment
Divides the Alignment in each dimension by the given factor.
override
operator ==(Object other) bool
The equality operator.
inherited
operator unary-() Alignment
Returns the negation of the given Alignment.
override
operator ~/(double other) Alignment
Integer divides the Alignment in each dimension by the given factor.
override

Static Methods

lerp(Alignment? a, Alignment? b, double t) Alignment?
Linearly interpolate between two Alignments.
override

Constants

bottomCenter → const Alignment
The center point along the bottom edge.
bottomLeft → const Alignment
The bottom left corner.
bottomRight → const Alignment
The bottom right corner.
center → const Alignment
The center point, both horizontally and vertically.
centerLeft → const Alignment
The center point along the left edge.
centerRight → const Alignment
The center point along the right edge.
topCenter → const Alignment
The center point along the top edge.
topLeft → const Alignment
The top left corner.
topRight → const Alignment
The top right corner.