Skip to main content

Flutter softWrap Text Example

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 :
Flutter softWrap Text Example
Screenshot with softWrap: false:
softWrap false in flutter
2. Complete source code for main.dart file:
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