flutter - Flutter:扩展的 IconButton 仍然显示在 Container 下
问题描述
AnimatedContainer(
...
child: Container(
child: Column(
children: [
Row(
children: [
Container(
width:60,
height:50,
color: Colors.black,
),
],
),
Expanded(
child: GestureDetector(
onTap: () {
print('what');
},
child: Container(
height: 50,
child: Column(
children: [
Expanded(
child: Text('asdf'),
),
Expanded(
child: IconButton(
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
我AnimatedContainer
这里有这个小部件。我的Text()
小部件和RaisedButton
小部件隐藏在盒子内。它们显示为AnimatedContainer
展开。但是,我IconButton
没有。
此外,Icon
小部件也像IconButton
小部件一样。AnimatedContainer
当像小部件一样拉伸时,我怎样才能让它出现Text
?
解决方案
我已经修改了你的代码,希望这是你想要的。
class _RowStructureState extends State<RowStructure> {
bool pressed = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
setState(() {
pressed = !pressed;
});
print(pressed);
},
child: Column(children: <Widget>[
AnimatedContainer(
height: pressed ? 120 : 50,
color: Colors.green,
duration: Duration(seconds: 1),
child: Stack(
children: [
Container(
height: 50,
width: 50,
color: Colors.black,
),
Positioned(
bottom:0,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('asd'),
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.ac_unit,),
onPressed: pressed?(){}:null,
),
],
),
)
],
),
)
]),
);
}
}
推荐阅读
- c++ - QTextEdit ANSI 符号
- javascript - 比较多个对象并将缺少的键添加到每个没有值的对象
- r - 如何在 rmakdown 中包含外部代码文件以使用 sintax 突出显示以 pdf 格式输出
- php - 在 FPDM 中对齐多行文本输入表单
- php - 将 qiuz 的答案与问题 ID 匹配
- python - 谁能解释我这段代码中的括号类?
- c# - Uri 类非常脆弱,似乎过度抛出异常
- weblogic - 如何在 WebLogic 服务器中设置环境变量
- android - 编辑文本输入类型电话 - 只允许 1 个小数
- amazon-web-services - 将照片上传到 S3 但上传将文件更改为文档