Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Alignment of Text widget flutter

I have to display two text, one below the other. But what is happening if upper text is long than below text comes in center but I want that starting point of both the text would remain same (No matter how long the text is).

enter image description here

See this above picture. First text is long so the below text is also not starting from the left. I have tried a lot but no success.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My code is as below:

return ListView.builder(
      itemCount: Model.length,
        itemBuilder: (context, index) {
          return Container(
            margin: const EdgeInsets.all(8.0),
            child: Card(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(15.0)
              ),
              child: Padding(
                padding: const EdgeInsets.all(15.0),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    ClipRRect(
                      borderRadius: BorderRadius.circular(15.0),
                      child: Image.network(
                          "${Model[index].image!}",
                        fit: BoxFit.fill,
                        height: 100,
                        width: 100
                      )
                    ),
                    Align(
                      alignment: Alignment.topLeft,
                      child: Column(
                        children: const [
                          Text("hhhhhhhhhhhhhhhh",
                          textAlign: TextAlign.end,
                          textDirection: TextDirection.ltr,),
                          Align(
                            alignment: Alignment.topLeft,
                            child: Text("ffff",
                              textAlign: TextAlign.start),
                          )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          );
        }
    );

How to achieve that both the text will start from the beginning only. If the text is long then the widget will increase the size but only from the end.?

>Solution :

Set the crossAxisAlignment of the Column to CrossAxisAlignment.start

Column(
  crossAxisAlignment: CrossAxisAlignment.start,
  children: const [
    Text("hhhhhhhhhhhhhhhh"),
    Text("ffff"),
  ],
),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading