Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a Text widget wrap long text into multiple lines?

Tags:

flutter

dart

I'm using a Stepper widget and I'm using a Text widget as the title parameter.

The string I use for my text is long, and I'd like it to wrap the text in multiple lines. How can I do that?

Here's the code I used to build this:

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Stepper(
          currentStep: currentStepIndex,
          onStepContinue: () => setState(() => currentStepIndex++),
          onStepTapped: (int index) => setState(() => currentStepIndex = index),
          steps: questions
              .map((String q) => Step(
                    title: Text(q),
                    content: QuestionWidget(),
                  ))
              .toList(),
        ),
      );

Here's what it currently looks like: enter image description here

like image 807
Pacane Avatar asked May 21 '18 14:05

Pacane


People also ask

How do you make the long text go to the next line in Flutter?

Here's how you wrap text on overflow in Flutter:Step 1: Make sure your Text widget is inside the Row widget. Step 2: Wrap your Text widget inside the Expanded widget. Step 3: Run your app.

How do you text multiple lines?

To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.

What tkinter class is good for displaying multiple lines of text in a GUI?

A text widget provides a multi-line text area for the user. The text widget instance is created with the help of the text class. It is also used to display text lines and also allows editing the text.


1 Answers

Use flexible if you just wanna make multiple lines:

Flexible (child: Text('Some text here'))
like image 127
rize Avatar answered Oct 21 '22 09:10

rize