Flutter 在颤振/省道中:在AppBar中显示两行文字?
我创建了一个appBar:它由一行组成:该行包含三个元素:一个图像/一个textwidget/另一个图像 代码如下:Flutter 在颤振/省道中:在AppBar中显示两行文字?,flutter,dart,containers,appbar,text-widget,Flutter,Dart,Containers,Appbar,Text Widget,我创建了一个appBar:它由一行组成:该行包含三个元素:一个图像/一个textwidget/另一个图像 代码如下: appBar: AppBar( automaticallyImplyLeading: false, title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 1,
child: Container(
child: BarIcon(
image: 'icons/back.png',
width: 55.0,
height: 75.0,
onTap: () => Navigator.pop(context),
),
),
),
Expanded(
flex: 5,
child: Container(
child: Text(
widget.thema.toUpperCase(),
style: TextStyle(
fontSize: 25.0,
),
textAlign: TextAlign.center,
),
),
),
Expanded(
flex: 1,
child: Container(
child: Image.asset(
widget.image,
height: 55.0,
width: 55.0,
),
),
),
],
),
图像显示很好,文本也很长,只要不太长。
然后,它不在两行上显示文本,而是添加“…”并剪切文本
当标题太长时,有没有办法在两行上显示?
文本通过“widget.thema”传递,因此不可能知道标题的长度。效果很好!谢谢!!当我看到“maxLines”时:我想,这恰恰是为了防止文本使用太多的行。。。谢谢你的帮助。
appBar: AppBar(
automaticallyImplyLeading: false,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 1,
child: Container(
child: BarIcon(
image: 'icons/back.png',
width: 55.0,
height: 75.0,
onTap: () => Navigator.pop(context),
),
),
),
Expanded(
flex: 5,
child: Container(
child: Text(
widget.thema.toUpperCase(),
style: TextStyle(
fontSize: 25.0,
),
maxLines: 2, // TRY THIS
textAlign: TextAlign.center,
),
),
),
Expanded(
flex: 1,
child: Container(
child: Image.asset(
widget.image,
height: 55.0,
width: 55.0,
),
),
),
],
),