Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align 2 text widgets in the same row to the start and end of a row in flutter?

Tags:

flutter

i have a row in flutter which contains 2 text widget, i want to add one text widget to the beginning of the row and another to the end:

this is my code :

  Row(
                            children: <Widget>[
                              Text(
                                "eshiett1995",
                                textAlign: TextAlign.left,
                                style: TextStyle(fontWeight: FontWeight.bold),
                              ),
                              Padding(padding: EdgeInsets.only(right: 10.0),),
                              Text(
                                "4:33am",
                                textDirection: TextDirection.ltr,
                                textAlign: TextAlign.left,
                                style: TextStyle(fontWeight: FontWeight.bold),
                              )

                            ],
                          ),

and presently this is how my code looks visually :

enter image description here

i want the eshiett1995 to stay at the beginning, while the time which is 4:33am, to move to the end

like image 705
Oto-obong Eshiett Avatar asked Nov 06 '18 23:11

Oto-obong Eshiett


People also ask

How do you align two text in a row in Flutter?

You just have to add the Row property mainAxisAlignment: MainAxisAlignment.

How do you align widgets at the end of a row of Flutter?

you can add Spacer(), above the widget you want to put at the end. Save this answer.


1 Answers

Did you try the Spacer class? https://docs.flutter.io/flutter/widgets/Spacer-class.html

Add Spacer widget between the two text.

like image 148
user1462442 Avatar answered Sep 22 '22 14:09

user1462442