align_positioned 1.0.6 copy "align_positioned: ^1.0.6" to clipboard
align_positioned: ^1.0.6 copied to clipboard

outdated

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) makes the child's right side touch the right side of the container (it touches the container from the inside).

But if touch is Touch.outside, then Alignment(1.0, 0.0) makes the child's left side touch the right side of the container (it touches the container from the outside).

Parameters dx and dy can be positive or negative, and move the child horizontally and vertically, in pixels.

Parameters childWidth and childHeight can be positive or negative, and move the child horizontally and vertically, but the unit here is not pixels, but child widths and heights.

Parameters containerWidth and containerHeight can be positive or negative, and move the child horizontally and vertically, but the unit here is not pixels, but container 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:

alt text

AlignPositioned(
   child: child,        
   alignment: Alignment.topLeft,
   touch: Touch.inside,
   dx: 15.0, // Move 4 pixels to the right. 
   childWidth: -0.5, // Move half child width to the left.  
   childHeight: -0.5); // Move half child height to the top.

Then, to move the child one container width to the right, and one container height to the bottom:

alt text

AlignPositioned(
   child: child,        
   alignment: Alignment.topLeft,
   touch: Touch.inside,
   dx: 15.0, // Move 4 pixels to the right. 
   childWidth: -0.5, // Move half child width to the left.  
   childHeight: -0.5, // Move half child height to the top.
   containerWidth: 1.0, // Move one container width to the right.
   containerHeight: 1.0); // Move one container height to the bottom.               

Please, check the example tab for the effects seen below:

alt text

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';
251
likes
0
pub points
94%
popularity

Publisher

verified publisherglasberg.dev

A widget that aligns and positions its child within itself.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on align_positioned