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 use 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:
- AlignmentDirectional, which has a horizontal coordinate orientation that depends on the TextDirection.
- AlignmentGeometry, which is an abstract type that is agnostic as to whether the horizontal direction depends on the TextDirection.
- Inheritance
- Object
- AlignmentGeometry
- Alignment
- Implementers
Constructors
Properties
- x → double
-
The distance fraction in the horizontal direction. [...]
final
- y → double
-
The distance fraction in the vertical direction. [...]
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
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. [...]
-
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 -
Returns a string representation of this object.
override
-
withinRect(
Rect rect) → Offset - Returns the point that is this fraction within the given rect.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
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 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
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
Constants
- bottomCenter → const Alignment
-
The center point along the bottom edge.
const Alignment(0.0, 1.0)
- bottomLeft → const Alignment
-
The bottom left corner.
const Alignment(-1.0, 1.0)
- bottomRight → const Alignment
-
The bottom right corner.
const Alignment(1.0, 1.0)
- center → const Alignment
-
The center point, both horizontally and vertically.
const Alignment(0.0, 0.0)
- centerLeft → const Alignment
-
The center point along the left edge.
const Alignment(-1.0, 0.0)
- centerRight → const Alignment
-
The center point along the right edge.
const Alignment(1.0, 0.0)
- topCenter → const Alignment
-
The center point along the top edge.
const Alignment(0.0, -1.0)
- topLeft → const Alignment
-
The top left corner.
const Alignment(-1.0, -1.0)
- topRight → const Alignment
-
The top right corner.
const Alignment(1.0, -1.0)