How to add new line to Text in Flutter?

This Article is posted by seven.srikanth at 9/21/2019 6:30:24 AM

In this article, I'm going to share a simple example of how to add new line to Text in Flutter. Before: ![](https://fluttercentral.com/Uploads/18f56d8e-ce53-45b2-8c66-23b9bdbe0a72.PNGwidth="50%height="auto]( After: ![](https://fluttercentral.com/Uploads/e6e54c4e-fff0-44e4-bedd-8a3824314c13.PNGwidth="50%height="auto]( This can be achieved by adding \n into your text widget as below. Text('Hello, \n How are you?',) Here is the code from main.dart file to achieve this. runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { double padValue = 0; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text("Text Example"), ), body: Center( child: Container( child: Text( 'Hello, \n How are you?', textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, style: TextStyle(fontWeight: FontWeight.bold), )), )), ); } }` Thanks, Srikanth

Tags: New Line; break line;



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.




© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com