Backward slash also known as backslash with small n character is used to divide a line from between in Flutter. Sometimes we have so much text in flutter mobile application and all the text seems to pushing each other. But using the \n(Backward slash with Small n) character we can Break Text Line From Middle in Flutter Android iOS mobile app.
Contents in this project Break Text Line From Middle in Flutter Android iOS Example:
1. Import material.dart package in your app’s main.dart file.
1 |
import 'package:flutter/material.dart'; |
2. Call our main MyApp class using void main runApp() method.
1 |
void main() => runApp(MyApp()); |
3. Create our main class named as MyApp extends with State less widget.
1 2 3 4 |
class MyApp extends StatelessWidget { } |
4. Creating Text widget with some random text message in Center Widget. As you can see in below text string we are using \n(Backslash n) using to breaking line from middle.
1 2 3 4 |
Center( child: Text('Hello Guys, Thanks \nfor visiting our website \nFlutter-Examples.com', style: TextStyle(fontSize: 22), textAlign: TextAlign.center) ) |
5. Complete source code for main.dart file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Break Text Line From Middle') ), body: Center( child: Text('Hello Guys, Thanks \nfor visiting our website \nFlutter-Examples.com', style: TextStyle(fontSize: 22), textAlign: TextAlign.center) ) ) ); } } |
Screenshot:
very helpful trick, helped me a lot