【发布时间】:2020-06-28 11:30:22
【问题描述】:
我正在尝试从 AppBar 底部制作抽屉。这是我到目前为止的地方
double height = 5;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text('Drawer'),
actions: <Widget>[
FlatButton(
child: Text('press'),
onPressed: () {
setState(() {
height == 5 ? height = 150 : height = 5;
});
},
)
],
),
body: Column(
children: <Widget>[
AnimatedContainer(
color: Colors.green,
duration: Duration(milliseconds: 500),
height: height,
child: ListView(
children: <Widget>[Text('hello')],
),
),
Container(
height: 200,
color: Colors.red,
)
],
),
);
}
它以某种方式工作正常,但是这个解决方案移动了底部容器,我需要那个抽屉在它后面,或者换句话说,在红色容器的顶部展开。另一个问题是,当您将Column 和一些孩子放在动画容器中时,内容就会溢出。最好的解决方案是将那个抽屉移到 AppBar 后面而不是改变我猜的大小
这是我尝试修复溢出但没有用的方法
AnimatedContainer(
color: Colors.green,
duration: Duration(milliseconds: 500),
height: height,
child: height == 5
? Container(color: Colors.green)
: Column(
children: <Widget>[Text('hello')],
),
)
【问题讨论】:
-
如果使用
Column,Stack会怎样? -
@dev-aentgs 我尝试使用堆栈并将列替换为堆栈使动画容器消失。你可以试试..我在我的问题中制作了简单的可重现代码..
-
如果订单发生变化,
Stack中的最后一个小部件将位于顶部。会尝试