Align vs Positioned in Flutter: Understanding When and How to Use Them
FlutterPulseThis article was translated specially for the channel FlutterPulseYou'll find lots of interesting things related to Flutter on this channel. Don't hesitate to subscribe!🚀

When building Flutter UIs, positioning widgets precisely is a common need. Two widgets often used for this are Align and Positioned. While…
When building Flutter UIs, positioning widgets precisely is a common need. Two widgets often used for this are Align and Positioned. While both are used to control where a widget appears, they serve different purposes and behave differently. In this post, we'll explore their differences, best use cases, and practical examples to make the right choice every time.
Understanding the Basics
Align Widget
- Positions its child relative to its parent using an
alignment. - Works with any widget, not restricted to layouts like
Stack. - Can also scale the child using
widthFactorandheightFactor.
Positioned Widget
- Only works inside a
Stack. - Positions the child using absolute distances from the stack's edges (
top,left,right,bottom). - Perfect for overlapping or fine-grained control.
Key Differences at a Glance
| Feature | `Align` | `Positioned` |
| ----------- | -------------------------------------------------- | ----------------------------------------------- |
| Used Inside | Any layout (commonly `Container`, `Column`, etc.) | Only inside a `Stack` |
| Positioning | Relative using `alignment` | Absolute using `top`, `left`, `right`, `bottom` |
| Sizing | Can scale child with `widthFactor`, `heightFactor` | Does not alter child size |
| Use Case | Aligning elements like buttons, text, etc. | Creating floating buttons, tooltips, badges |
Real-World Example 1: Aligning a Login Button
Let's say you're creating a login screen and you want the "Login" button to always stay at the bottom center of the screen, regardless of screen size.
Scaffold(
body: Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
onPressed: () {},
child: Text('Login'),
),
),
),
)
Why Align?
- The button moves dynamically with the screen size.
- No need for a
Stack. - Alignment is simple and responsive.
Real-World Example 2: Overlay a Badge on an Icon
You want to show a small red badge on the top-right of a shopping cart icon. This is a classic use of Stack and Positioned.
Stack(
children: [
Icon(Icons.shopping_cart, size: 40),
Positioned(
right: 0,
top: 0,
child: Container(
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
child: Text(
'3',
style: TextStyle(color: Colors.white, fontSize: 12),
),
),
),
],
)
Why Positioned?
- Precise placement over another widget.
- Allows overlap and pixel-perfect control.
Conclusion
- Use
AlignWhen you want relative positioning and responsiveness. - Use
PositionedWhen you want exact placement inside aStack. - Don't forget that
Alignis great for flexible UI, whilePositionedis perfect for layered designs.
Both are powerful tools in your Flutter UI toolkit. Choosing the right one depends on your layout needs.
For more details, refer to the official Flutter documentation on Align Widget and Positioned Widget.
Here to make the community stronger by sharing our knowledge. Follow me and my team to stay updated on the latest and greatest in the web & mobile tech world.