I am trying to align the name to the left side but it is not working. Always displays in the center suppose I use text-align. So, How to resolve this issue?
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Name",
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
textAlign: TextAlign.left,
style: const TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold,),
),
const SizedBox( width: 160,
child:Text(
"[email protected]",
maxLines: 3,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: const TextStyle(
fontSize: 12,
color: Colors.black,
),
),),
],
),
CodePudding user response:
In column
widget add this line :
crossAxisAlignment: CrossAxisAlignment.start
and remove :
mainAxisAlignment: MainAxisAlignment.center,
CodePudding user response:
Add this to column
:
crossAxisAlignment: CrossAxisAlignment.start,
CodePudding user response:
Warp your column with Container and then inside the container enter below line:
alignment:Alignment.center
CodePudding user response:
add Container for the text and give it alignment
Like this:
Container(
alignment: Alignment.centerLeft,
child:Text('text here')
)
And you want display the name and email together use Row
Like this:
Row(
mainAxisAlignment: MainAxisAlignment.start,
children:[
Text("name:"),
Text("[email protected]"),
]
)
And the output well be like this:
Name: [email protected]
CodePudding user response:
Container( alignment: Alignment.centerLeft, child:Text('text here',textalign:center)
)