Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to wrap text for android app in flutter

I am developing android app using flutter and In my application trying to warp the text to next line but it is not working. In my app mail id is not wrapping. It is coming in the straight line. But i want to wrap the text in the next line. So, How to show the wrap text(mail id) in the next line in the flutter.

If anyone knows the answer please help to find the solution.

 Widget build(BuildContext context)
 {
 return Drawer(
  child: ListView(
    children: [
      //drawer header
      Container(
        height: 165,
        color: Colors.amber,
        child: DrawerHeader(
          decoration:  BoxDecoration(color: Color(0xFFF5F1F1)),
          child: Row(
            children: [
              const Icon(
                Icons.person,
                size: 50,
                color: Colors.black,
              ),

              const SizedBox(width: 16,),

              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    "Name",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    softWrap: false,
                    style: const TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold,),
                  ),
                  const SizedBox(height: 10,),
                  Text(
                    "mynameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee@gmail.com",
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis,
                    softWrap: true,
                    style: const TextStyle(
                      fontSize: 12,
                      color: Colors.black,
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),

      const  SizedBox(height: 12.0,),

      //drawer body
      GestureDetector(
        onTap: ()
        {
          Navigator.push(context, MaterialPageRoute(builder: (c)=> TripsHistoryScreen()));
        },
        child: const ListTile(
          leading: Icon(Icons.history, color: Colors.black,),
          title: Text(
            "History",
            style: TextStyle(
              color: Colors.black
            ),
          ),
        ),
      ),

      GestureDetector(
        onTap: ()
        {
          Navigator.push(context, MaterialPageRoute(builder: (c)=> ProfileScreen()));
        },
        child: const ListTile(
          leading: Icon(Icons.person, color: Colors.black,),
          title: Text(
            "Visit Profile",
            style: TextStyle(
                color: Colors.black
            ),
          ),
        ),
      ) 

    ],
  ),
);
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Wrap the Text widget with SizedBox with fixed width.


SizedBox(
                 width: 200,
                 child:Text(
                 "mynameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee@gmail.com",
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis,
                    softWrap: true,
                    style: const TextStyle(
                      fontSize: 12,
                      color: Colors.black,
                    ),
                  ),
),

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading