Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are AlignmentDirectional and AlignmentGeometry in Flutter

I understand alignment: Alignment(-1, 0), and alignment: Aignment.topLeft, etc. but what are AlignmentDirectional, AlignmentGeometry. I can't understand the docs very well.

like image 214
user3808307 Avatar asked Oct 19 '25 04:10

user3808307


1 Answers

AlignmentGeometry is the abstract type which Alignment and AlignmentDirectional implement. The whole idea is to define the relative positioning of two widgets (mostly a child and its parent). It has abstract methods to calculate result of interactions between two, scaling, adding, .... These methods are implemented by Alignment and AlignmentDirectional.

Alignment adds more details and helper functions, like the ones you mentioned: Alignment(-1, 0), Aignment.topLeft, .... And this is what we most of the times use.

AlignmentDirectional is just like Alignment but is aware of TextDirection. It is useful in Left-to-Right languages where you want the horizontal direction to be automatically based on the TextDirection without you having to do any more calculations. As the doc says:

This can be used to indicate an offset from the left in TextDirection.ltr text and an offset from the right in TextDirection.rtl text without having to be aware of the current text direction.

like image 100
Sohail Avatar answered Oct 22 '25 00:10

Sohail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!