您可以解决将
Text小部件包装到
Flexible以避免溢出的问题。我把maxLines 1放到Fade上看:
new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Flexible(child: new Text( "Account Name: Let's Flutter all day long till down with fancy User Interface", maxLines: 1, style: new TextStyle( fontSize: myTextSize, color: Colors.black54), overflow: TextOverflow.fade,), ), new Text("109.65",style: new TextStyle( fontSize: myTextSize, fontWeight: FontWeight.bold, color: Colors.black),overflow: TextOverflow.fade, ), ], ),我添加了一个全局变量:
var myTextSize = 12.0;
您也可以使用
LayoutBuilder来获取设备的
maxHeight或
maxWidth,之后您可以像以下示例一样更改文本大小:
var myTextSize = 12.0; return LayoutBuilder(builder: (context, boxConstraints) { print(boxConstraints.maxHeight); if (boxConstraints.maxHeight <= 667.0){ myTextSize = 10.0; } return Container( child: new ListTile( trailing: new Icon(Icons.chevron_right), onTap: () {}, title: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text( "My Account Details:", style: new TextStyle(fontSize: 14.0,fontWeight: FontWeight.bold,color: Colors.black), overflow: TextOverflow.fade, ), ], ), subtitle: new Column( children: <Widget>[ new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text("Hello Flutter",style: new TextStyle( fontSize: myTextSize, color: Colors.black54),overflow: TextOverflow.fade, ), new Text("Today is **************",style: new TextStyle( fontSize: myTextSize, color: Colors.black54),overflow: TextOverflow.fade, ), ], ), new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text("Name",style: new TextStyle( fontSize: myTextSize, color: Colors.black54),overflow: TextOverflow.fade, ), new Text("Dart",style: new TextStyle( fontSize: myTextSize, color: Colors.black54),overflow: TextOverflow.fade, ), ], ), new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text("Surname",style: new TextStyle( fontSize: myTextSize, color: Colors.black54),overflow: TextOverflow.fade, ), new Text("Flutter",style: new TextStyle( fontSize: myTextSize, fontWeight: FontWeight.bold, color: Colors.black),overflow: TextOverflow.fade, ), ], ), new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Flexible(child: new Text( "Account Name: Let's Flutter all day long till down with fancy User Interface", maxLines: 1, style: new TextStyle( fontSize: myTextSize, color: Colors.black54), overflow: TextOverflow.fade,), ), new Text("109.65",style: new TextStyle( fontSize: myTextSize, fontWeight: FontWeight.bold, color: Colors.black),overflow: TextOverflow.fade, ), ], ), ], ), ), ); });


