Flutter 如何防止水平溢流?
我正在努力使这项工作,但我尝试了一切,但仍然不能使这项工作。因此,我的结构如下:Flutter 如何防止水平溢流?,flutter,flutter-layout,Flutter,Flutter Layout,我正在努力使这项工作,但我尝试了一切,但仍然不能使这项工作。因此,我的结构如下: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ CircleAvatar( radius: 40.0, backgroundImage: Image .network( '$thumbnail',
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
CircleAvatar(
radius: 40.0,
backgroundImage: Image
.network(
'$thumbnail',
fit: BoxFit.cover,
)
.image,
),
SizedBox(
width: 20,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Really biiiig drink name here',
style: TextStyle(
color: Colors.white,
fontSize: 28
),
),
Text(
'Category goes here',
style: TextStyle(
color: Colors.white.withOpacity(.8)
),
),
],
),
],
),
行(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
圆形(
半径:40.0,
背景图片:图片
.网络(
“$thumbnail”,
适合:BoxFit.cover,
)
.图像,
),
大小盒子(
宽度:20,
),
纵队(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
“这里真的有很多酒名”,
样式:TextStyle(
颜色:颜色,白色,
尺寸:28
),
),
正文(
“分类在这里”,
样式:TextStyle(
颜色:颜色。白色。不透明度(.8)
),
),
],
),
],
),
它呈现如下:
如何在不为父窗口小部件定义固定宽度的情况下剪裁或包装标题文本?将
扩展的
添加到您的内部列中,为其指定定义的宽度
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
CircleAvatar(
radius: 40.0,
backgroundImage: Image.network(
'$thumbnail',
fit: BoxFit.cover,
).image,
),
SizedBox(
width: 20,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Really biiiig drink name here',
style: TextStyle(
color: Colors.white,
fontSize: 28
),
),
Text(
'Category goes here',
style: TextStyle(
color: Colors.white.withOpacity(.8)
),
),
],
),
),
],
);
行(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
圆形(
半径:40.0,
背景图片:Image.network(
“$thumbnail”,
适合:BoxFit.cover,
).图像,
),
大小盒子(
宽度:20,
),
扩大(
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
“这里真的有很多酒名”,
样式:TextStyle(
颜色:颜色,白色,
尺寸:28
),
),
正文(
“分类在这里”,
样式:TextStyle(
颜色:颜色。白色。不透明度(.8)
),
),
],
),
),
],
);
如果在发生溢出的位置添加扩展,应该可以解决问题。使用扩展的
小部件来防止视图溢出
行(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
圆形(
半径:40.0,
背景图片:Image.network('https://i.stack.imgur.com/LJ30b.png,适合:BoxFit.cover,)。图像,
),
大小盒子(
宽度:20,
),
扩展(子:列)(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
“这里真的有很多酒名”,
样式:TextStyle(
颜色:颜色,黄色,
尺寸:28
),
),
正文(
“分类在这里”,
样式:TextStyle(
颜色:颜色。红色。不透明度(.8)
),
),
],
), ),
],
),
检查此答案将您的列
包装在扩展的
WidgetCombing@OMiShah answer和ChyperX中,我实现了我想要的。谢谢你们,接受这个答案,每个答案都是一样的。非常感谢。
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
CircleAvatar(
radius: 40.0,
backgroundImage: Image.network('https://i.stack.imgur.com/LJ30b.png', fit: BoxFit.cover,).image,
),
SizedBox(
width: 20,
),
Expanded(child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Really biiiig drink name here',
style: TextStyle(
color: Colors.yellow,
fontSize: 28
),
),
Text(
'Category goes here',
style: TextStyle(
color: Colors.red.withOpacity(.8)
),
),
],
), ),
],
),