Reputation: 195
How could I wrap the text widget inside a stepper widget subtitle?, These are some attempts I made without success:
return Scaffold(
body: Stepper(
steps: [
Step(
title: Text("fake title"),
subtitle: Text(
"This text should be only one line, if flutter is showing an error and you are tired of trying to find a solution, start praying.",
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: true,
),
content: Text("fake content")),
],
));
And with a expandable or flexible widget:
return Scaffold(
body: Stepper(
steps: [
Step(
title: Text("fake title"),
subtitle: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
"This text should be only one line, if flutter is showing an error and you are tired of trying to find a solution, start praying.",
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: true,
),
],
),
)
],
),
content: Text("fake content")),
],
));
The only way I achieved was using a Container widget, but I had to specify a fixed width, so it was not responsive.
Upvotes: 1
Views: 1049
Reputation: 103401
I found that there is margin/padding like 84.0 (is not exactly), where you can use to set the width like this code:
@override
Widget build(BuildContext context) {
return Scaffold(body: LayoutBuilder(
builder: (context, constraints) {
return Stepper(
steps: [
Step(
title: Text("fake title"),
subtitle: SizedBox(
width: constraints.maxWidth - 84,
child: Text(
"This text should be only one line, if flutter is showing an error and you are tired of trying to find a solution, start praying.",
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
),
content: Text("fake content"),
),
],
);
},
));
}
Upvotes: 2