The softWrap property of Text enables text wrapping in flutter. By default in flutter if we defines a long text then it will only wrap in 1 line if given text parent has no height width defined. Other then 1 line text will be hidden from the screen. But using softWrap: true we can show all the text on screen event its parent has not width height defined case. See the below example of then you will understand properly.
Flutter softWrap Text Example:
1. Applying softWrap: true on Text component.
Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
style: TextStyle(fontSize: 28),
softWrap: true,
)
Screenshot with softWrap: true :
import 'package:flutter/material.dart';
void main() => runApp(const App());
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
style: TextStyle(fontSize: 28),
softWrap: true,
))),
);
}
}
Comments
Post a Comment