Flutter 右部件在颤振中完全可见
我希望两个小部件相邻,而正确的小部件总是完全可见的。在这种情况下,这两个图标并不完全可见 这是我的源代码方法,但它不适用于Flutter 右部件在颤振中完全可见,flutter,Flutter,我希望两个小部件相邻,而正确的小部件总是完全可见的。在这种情况下,这两个图标并不完全可见 这是我的源代码方法,但它不适用于溢出:TextOverflow.省略号。 我使用这些小部件的目的是让左侧的文本以 … 如果他们的时间太长如何使小部件2始终完全可见? new Row(children: <Widget>[ // ### Widget 1 ### new Column(children: <Widget>[ ne
溢出:TextOverflow.省略号。
我使用这些小部件的目的是让左侧的文本以
…
如果他们的时间太长如何使小部件2始终完全可见?
new Row(children: <Widget>[
// ### Widget 1 ###
new Column(children: <Widget>[
new Text("A very long strings sassaasasasasasasssss", overflow: TextOverflow.ellipsis),
new Text("Another very long string skaskajsakaskjsa", overflow: TextOverflow.ellipsis),
]),
// ### Widget 2 ###
/* should be visible in full size on the right in every situation */
new Expanded(child:
new Row(
children: <Widget>[
new Container(
child: new IconButton(icon: new Icon(Icons.check, color: Colors.green, size: 35.0), onPressed: () async {
}),
margin: new EdgeInsets.only(right: 10.0),
),
new IconButton(icon: new Icon(Icons.remove, color: Colors.red, size: 35.0), onPressed: () async {
}),
],
mainAxisSize: MainAxisSize.min
)
),
]
),
新行(子项:[
//####小部件1###
新栏目(儿童:[
新文本(“一个很长的字符串sassassss”,溢出:textfoverflow.省略号),
新文本(“另一个很长的字符串skaskajsakaskjsa”,溢出:TextOverflow.省略号),
]),
//####小部件2###
/*在任何情况下都应在右侧完全可见*/
新扩展(儿童:
新行(
儿童:[
新容器(
子项:新建图标按钮(图标:新建图标(Icons.check,颜色:Colors.green,大小:35.0),ON按下:()异步{
}),
边距:仅限新边集(右:10.0),
),
新建图标按钮(图标:新建图标(Icons.remove,颜色:Colors.red,大小:35.0),ON按下:()异步{
}),
],
mainAxisSize:mainAxisSize.min
)
),
]
),
您可以使用带有已实现的尾随的
,它只需在行的末尾添加一个小部件:
ListTile(
title: Widget1,
trailing: new Row(
children: <Widget> [
IconButton,
IconButton
]
),
)
listile(
标题:Widget1,
尾随:新行(
儿童:[
IconButton,
图标按钮
]
),
)
您可以使用带有已实现的尾随的
,它只需在行的末尾添加一个小部件:
ListTile(
title: Widget1,
trailing: new Row(
children: <Widget> [
IconButton,
IconButton
]
),
)
listile(
标题:Widget1,
尾随:新行(
儿童:[
IconButton,
图标按钮
]
),
)
问题是您的文本
小部件位于列
小部件中,它可以根据其子部件(在本例中为文本
小部件)调整大小。因此,overflow:TextOverflow.省略号在这里不会做任何事情,除非您将文本小部件包装到列中
解决此问题的一种方法是使用小部件包装列
小部件,并根据需要使用属性
固定代码应如下所示:
new Row(children: <Widget>[
// ### Widget 1 ###
new Flexible( // newly added
flex: 2, // newly added
child: new Column(
mainAxisSize: MainAxisSize.min, // newly added
crossAxisAlignment: CrossAxisAlignment.start, // newly added
children: <Widget>[
new Text("A very long strings sassaasasasasasasssss",
overflow: TextOverflow.ellipsis),
new Text("Another very long string skaskajsakaskjsa",
overflow: TextOverflow.ellipsis),
],
),
),
// ### Widget 2 ###
/* should be visible in full size on the right in every situation */
new Expanded(
child: new Row(
//mainAxisSize: MainAxisSize.min, // coomented because will not do anything here
children: <Widget>[
new Container(
child: new IconButton(
icon: new Icon(Icons.check,
color: Colors.green, size: 35.0),
onPressed: () async {}),
margin: new EdgeInsets.only(right: 10.0),
),
new IconButton(
icon: new Icon(Icons.remove, color: Colors.red, size: 35.0),
onPressed: () async {}),
],
)),
]),
新行(子项:[
//####小部件1###
新增柔性(//新增
flex:2,//新添加
子:新列(
mainAxisSize:mainAxisSize.min,//新添加
crossAxisAlignment:crossAxisAlignment.start,//新添加
儿童:[
新文本(“非常长的字符串sassassasss”,
溢出:text溢出。省略号),
新文本(“另一个很长的字符串skaskajsakaskjsa”,
溢出:text溢出。省略号),
],
),
),
//####小部件2###
/*在任何情况下都应在右侧完全可见*/
新扩展(
孩子:新的一排(
//mainAxisSize:mainAxisSize.min,//coomented,因为在这里不会执行任何操作
儿童:[
新容器(
孩子:新的图标按钮(
图标:新图标(Icons.check,
颜色:彩色。绿色,尺寸:35.0),
onPressed:()异步{}),
边距:仅限新边集(右:10.0),
),
新图标按钮(
图标:新图标(Icons.remove,颜色:Colors.red,大小:35.0),
onPressed:()异步{}),
],
)),
]),
问题是您的文本
小部件位于列
小部件中,它可以根据其子部件(在本例中为文本
小部件)调整大小。因此,overflow:TextOverflow.省略号在这里不会做任何事情,除非您将文本小部件包装到列中
解决此问题的一种方法是使用小部件包装列
小部件,并根据需要使用属性
固定代码应如下所示:
new Row(children: <Widget>[
// ### Widget 1 ###
new Flexible( // newly added
flex: 2, // newly added
child: new Column(
mainAxisSize: MainAxisSize.min, // newly added
crossAxisAlignment: CrossAxisAlignment.start, // newly added
children: <Widget>[
new Text("A very long strings sassaasasasasasasssss",
overflow: TextOverflow.ellipsis),
new Text("Another very long string skaskajsakaskjsa",
overflow: TextOverflow.ellipsis),
],
),
),
// ### Widget 2 ###
/* should be visible in full size on the right in every situation */
new Expanded(
child: new Row(
//mainAxisSize: MainAxisSize.min, // coomented because will not do anything here
children: <Widget>[
new Container(
child: new IconButton(
icon: new Icon(Icons.check,
color: Colors.green, size: 35.0),
onPressed: () async {}),
margin: new EdgeInsets.only(right: 10.0),
),
new IconButton(
icon: new Icon(Icons.remove, color: Colors.red, size: 35.0),
onPressed: () async {}),
],
)),
]),
新行(子项:[
//####小部件1###
新增柔性(//新增
flex:2,//新添加
子:新列(
mainAxisSize:mainAxisSize.min,//新添加
crossAxisAlignment:crossAxisAlignment.start,//新添加
儿童:[
新文本(“非常长的字符串sassassasss”,
溢出:text溢出。省略号),
新文本(“另一个很长的字符串skaskajsakaskjsa”,
溢出:text溢出。省略号),
],
),
),
//####小部件2###
/*在任何情况下都应在右侧完全可见*/
新扩展(
孩子:新的一排(
//mainAxisSize:mainAxisSize.min,//coomented,因为在这里不会执行任何操作
儿童:[
新容器(
孩子:新的图标按钮(
图标:新图标(Icons.check,
颜色:彩色。绿色,尺寸:35.0),
onPressed:()异步{}),
边距:仅限新边集(右:10.0),
),
新图标按钮(
图标:新图标(Icons.remove,颜色:Colors.red,大小:35.0),
onPressed:()异步{}),
],
)),
]),
谢谢。我喜欢这个版本,它很简单,真的很好!不过,标题小部件前面有一点空白。谢谢。我喜欢这个版本,它很简单,真的很好!不过,标题小部件前面有一点空白。谢谢。这是一个比第一个答案更复杂的版本。但是你的版本也给了用户界面设计更多的自由。谢谢。这是一个比第一个答案更复杂的版本。但是你的版本也给了用户界面设计更多的自由。