【发布时间】:2020-09-15 04:44:26
【问题描述】:
当 FlatButton 的文本溢出时,我尝试使用省略号。
它适用于普通的 FlatButton,但不适用于 FlatButton.icon。我将不胜感激。
void main() => runApp(Test());
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
// bottomNavigationBar: BottomAppBar(child: widgetOk()),
bottomNavigationBar: BottomAppBar(child: widgetNotOk()),
),
);
}
}
Widget widgetOk() {
return Row(
children: <Widget>[
Flexible(
child: FlatButton(
child: Text('0123456789' * 10, overflow: TextOverflow.ellipsis),
onPressed: () {},
),
),
Flexible(
child: FlatButton(
child: Text('0123456789' * 10, overflow: TextOverflow.ellipsis),
onPressed: () {},
),
),
],
);
}
Widget widgetNotOk() {
return Row(
children: <Widget>[
Flexible(
child: FlatButton.icon(
icon: Icon(Icons.bug_report),
label: Text('0123456789' * 10, overflow: TextOverflow.ellipsis),
onPressed: () {},
),
),
Flexible(
child: FlatButton.icon(
icon: Icon(Icons.bug_report),
label: Text('0123456789' * 10, overflow: TextOverflow.ellipsis),
onPressed: () {},
),
),
],
);
}
【问题讨论】:
标签: flutter layout flutter-layout ellipsis