How to add new line to Text in Flutter?

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



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


Tags: New Line; break line;








0 Comments
Login to comment.
Recent Comments