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.

How to Solve textAlign not working flutter?
- 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.
- 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

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

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
- error: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’)
- type ‘int’ is not a subtype of type ‘String’ error in Dart
- CocoaPods not installed or not in valid state
- Error: Null safety features are disabled for this library
- flutter_localizations from SDK depends on intl 0.17.0 and fstore depends on intl ^0.16.1, flutter_localizations from SDK is forbidden
Leave a Reply