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:
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.
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.
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.
Use flexible if you just wanna make multiple lines:
Flexible (child: Text('Some text here'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With