Home > Mobile >  How to align Text- left, right and center into Flutter?
How to align Text- left, right and center into Flutter?

Time:12-23

I have three text- named as News-Title, News-date, and News-description. I want News title alignment as left, below to news-title want news-date right aligned and below to news-date wants news-description with center alignment.

please suggest proper solution.....

CodePudding user response:

Try below code hope its help to you. just set Alignment in your column refer image

CodePudding user response:

Use Align. You can choose alignment property value based on requirements.

Align(
   alignment: Alignment.topLeft,
   child: Text(
          "News Title",
          style: TextStyle(
          color: Colors.black),
   )
),

CodePudding user response:

Have you try to use TextAllignment.center/ left/ right? or you could wrap it in the Allign class from here https://api.flutter.dev/flutter/widgets/Align-class.html

CodePudding user response:

Either -

Align(
   alignment: Alignment.topLeft,
   child: Text(
          "News Title",
          style: TextStyle(
          color: Colors.black),
   )
),

Or that -

Text(
              "News Title",
              textAlign: TextAlign.center //example
              style: TextStyle(
              color: Colors.black),)
  • Related