Search code examples
flutterflutter-layout

How to align text in flutter


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(
                          "mynameee@gmail.com",
                          maxLines: 3,
                          overflow: TextOverflow.ellipsis,
                          softWrap: true,
                          style: const TextStyle(
                            fontSize: 12,
                            color: Colors.black,
                          ),
                        ),),

                    ],
         ),

Solution

  • In column widget add this line :

    crossAxisAlignment: CrossAxisAlignment.start
    

    and remove :

    mainAxisAlignment: MainAxisAlignment.center,