align_positioned 1.0.1 align_positioned: ^1.0.1 copied to clipboard
A widget that aligns and positions its child within itself.
align_positioned #
A widget that aligns and positions its child within itself.
The alignment
parameter works as expected. For example,
Alignment.bottomRight
represents the bottom right of the container,
and Alignment(0.0, 0.0)
represents the center of the container.
The distance from -1.0 to +1.0 is the distance from one side of the rectangle
to the other side of the rectangle.
If touch
is Touch.inside
, then alignment
works just like the alignment
for the Align
widget, aligning the child inside of the container.
However, if touch
is Touch.outside
, then the alignment happens outside of
the container.
As another example, if touch
is Touch.inside
, then Alignment(1.0, 0.0)
is touching
the right edge of the container from the inside. But if touch
is Touch.outside
,
then Alignment(1.0, 0.0)
is touching the right edge of the container from the outside.
Parameters dx
and dy
can be positive or negative, and move the child horizontally and
vertically, in pixels.
Parameters dWidth
and dHeight
can be positive or negative, and move the child horizontally and
vertically, but the unit here is not pixels, but child widths and heights.
Example #
The below image shows the center of the child positioned 15 pixels to the right of the top-left corner of the container:
AlignPositioned(
child: child,
alignment: Alignment.topLeft,
touch: Touch.inside,
dx: 15.0, // Move 4 pixels to the right.
dWidth: -0.5 // Move half child width to the left.
dHeight: -0.5); // Move half child height to the top.
Please, check the example tab for the effects seen below:
Usage #
Import the package #
First, add align_positioned as a dependency in your pubspec.yaml
Then, import it:
import 'package:align_positioned/align_positioned.dart';