Search code examples
flutterdartflutter-layouttransform

How to transform Flutter widget so origin is in the lower left corner?


Is there a simple way to set up a widget so that the origin is in the lower left corner of the widget, rather than the upper left corner?


Solution

  • If I understand this well, then yes you can with the Align widget let's say that I have this :

    Container(
      width: 200,
      height: 200,
      child: Text("text example")
    ),
    

    I can wrap the Text widget to show the text in Any plce inside the Container

      Container(
      width: 200,
      height: 200,
      child: Align(
        alignment: Alignment.bottomRight,
      child: Text("text example"),
      ),
    ),
    

    this will align the text widget in the bottom right of the Container.

    you can also align with the Alignment constructor like this

    Container(
      width: 200,
      height: 200,
      child: Align(
        alignment: Alignment(-1, 1),
      child: Text("text example"),
      ),
    ),
    

    you can play with values in the range -1<value<1