close
textAlign not working flutter, textAlign not working, textalign not, textalign not working in flutter, textalign property not working in flutter

[Solved] textAlign not working flutter

Hello Guys How are you all? Hope You all are fine. I am trying to align my Text in my app but textAlign not working in flutter. So today Here I come with all possible solutions for this error.

We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.

How Error Occurs ?

I am trying to align my Text in my app but textAlign not working in flutter. Here is My code

          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(
                "This Should be left",
                textAlign: TextAlign.left,
              ),
              Text(
                "This Should be right",
                textAlign: TextAlign.right,
              )
            ],
          ),

Here Is my Output.

textalign property not working in flutter

How to Solve textAlign not working flutter?

  1. How to Solve textAlign not working flutter?

    to Solve textAlign not working flutter This error occurs because your Text property does not contain full-width that's why your TextAlign not working. To solve textAlign not working flutter just use Align Widget.

  2. textAlign not working flutter

    to Solve textAlign not working flutter This error occurs because your Text property does not contain full-width that's why your TextAlign not working. To solve textAlign not working flutter just use Align Widget.

Solution 1: Use Align Widget

This error occurs because your Text property does not contain full-width that’s why your TextAlign not working. To solve textAlign not working flutter just use Align Widget.

Here is Example.

          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Align(
                alignment: Alignment.centerLeft,
                child: Container(
                  child: Text(
                    "This Should be left",
                  ),
                ),
              ),
              Align(
                alignment: Alignment.centerRight,
                child: Container(
                  color: Colors.red,
                  child: Text(
                    "This Should be Right",
                  ),
                ),
              ),
            ],
          ),

Here is Output

textAlign not working

Solution 2: use SizedBox with an infinite width.

Just use Wrap your Text widget to SizedBox and give all of width.

Example

          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(
                width: double.infinity,
                child: Container(
                  child: Text(
                    "This Should be left",
                    textAlign: TextAlign.start,
                  ),
                ),
              ),
              SizedBox(
                width: double.infinity,
                child: Container(
                  child: Text(
                    "This Should be left",
                    textAlign: TextAlign.end,
                  ),
                ),
              ),
            ],
          ),

Output

textAlign not working flutter

Summery

So, It’s All About this error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below on which solution worked for you. Thank You.

Also Check Out Below Tutorials


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *