What is the difference between using Align or using Positioned flutter
Positioned
is an offset based alignment which uses DP as unitAlign
use a % of the parent size
As such, Alignment(0.1, 0.1)
cannot be represented using a Positioned
. And similarly,Align
cannot represent a Positioned(top: 10, left: 10)
.
Secondly, Positioned
is on a different flow.
Stack
can size itself based on the size of one of its children excluding Positioned
widgets.
As such, using an Align
vs Positioned
can result in Stack
taking a different size.
Positioned
can only be used within a Stack
and positions a child relative to the Stack
size.
https://docs.flutter.io/flutter/widgets/Positioned-class.html
Align
will be as big as possible within its parent (or a size relative to the children if heightFactor
, widthFactor
are passed) and positions its child relative to itself. Align
can be used everywhere, not only within a Stack
.