I have an appbar that looks like this:
The user can change the text in the appbar. However, a text that is too long causes an overflow error:
I figured wrapping the specific Text inside a Flexible widget would solve this issue but I get an error that I could not fix when using the Flexible approach:
RenderBox was not laid out: RenderFlex#0ac34 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Here is the working code from the screenshots:
PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight + 60),
child: Container(
color: getAppBarColor(),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Visibility(
visible: hasBack,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(Icons.arrow_back_ios,
color: getContentColor()),
),
),
Text(
title,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: fontSize,
color: getContentColor(),
fontWeight: FontWeight.w600,
),
)
],
),
),
const Spacer(),
Visibility(
visible: hasSettings,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: getIconButton(context),
),
),
...getExtraIconButton()
],
),
],
),
),
)
I want the text to be dynamically abbreviated with "..." if he is too long. A dirty fix was to use a SizedBox, however, I would somehow need the SizedBox to have a non-static width for it to work on every device.
How do I achieve the desired behaviour?

