In this article, I'm going to share a simple example of how to add new line to Text in Flutter.
Before:
After:
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.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
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