在Android中match_parent,wrap_content用于相对于其父级自动调整窗口小部件的大小.
在Flutter中,默认情况下似乎所有小部件都设置为wrap_content,我如何更改它以便我可以填充它width和height它的父节点?
TL; DR需要容器填充垂直空间,以便它可以充当ontap监听器.尝试了大多数解决方案但似乎没有任何效果.
所以我要做的是让我的容器填满垂直空间,同时仍然有一个固定的宽度.第一个是我拥有的,第三个是我想要的.这个想法是让容器透明,带有一个手势ontap监听器.如果有人对不同的解决方案有更好的想法,请随时提出建议.
Widget build(BuildContext context) {
return new GestureDetector(
onHorizontalDragUpdate: _move,
onHorizontalDragEnd: _handleDragEnd,
child: new Stack(
children: <Widget>[
new Positioned.fill(
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Container(
child: new IconButton(
padding: new EdgeInsets.only(top: 16.0, bottom: 16.0, left: 24.0, right: 24.0),
icon: new Icon(Icons.warning),
color: Colors.black12,
onPressed: () {},
)
),
],
),
),
new SlideTransition(
position: new Tween<Offset>(
begin: Offset(0.0, 0.0),
end: const Offset(-0.6, 0.0),
).animate(_animation),
child: new Card(
child: new Row(
children: <Widget>[
new …Run Code Online (Sandbox Code Playgroud) 我有一个连续的图像和该图像旁边的文本。我希望该行完全展开,图像作为其大小,然后保持完整区域应由 Container 使用。
这是我的代码片段:
Row(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(10, 50, 10, 8),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color.fromARGB(100, 0, 0, 0),
blurRadius: 5,
),
],
),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Column(children: <Widget>[
Image.asset(
'assets/card.png',
height: 62,
width: 62,
fit: BoxFit.cover,
)
]),
Container(
child: Text("Hello world"),
)
],
),
),
],
),
Run Code Online (Sandbox Code Playgroud)
我想要这样: Flutter UI
我想用白色容器覆盖卡片,但容器总是需要一个高度(否则它不会显示).我希望它和它的父,堆栈一样大.我怎样才能做到这一点?卡的高度各不相同.我想我错过了一些东西;)
return new Stack(
children: <Widget>[
new Card( ... ),
new Container(color: Colors.white70),
]
);
Run Code Online (Sandbox Code Playgroud)