flutter - 为什么导入的小部件未显示在主屏幕颤动中
问题描述
我有一个主屏幕,我想导入另一个包含 3 个按钮的小部件。但是,小部件未显示在主屏幕中。
主文件中的代码:
Padding(
padding: EdgeInsets.only(left: 40.0),
child: Row(
children: <Widget>[
Text('Your',
style: TextStyle(color: Colors.white, fontSize: 25.0)),
SizedBox(
width: 10.0,
),
Text('Invoice',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 25.0))
],
)),
SizedBox(height: 40.0),
Container(
height: MediaQuery.of(context).size.height - 185.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.only(topLeft: Radius.circular(75.0))),
child: ListView(
primary: false,
padding: EdgeInsets.only(left: 25.0, right: 20.0),
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 45.0),
child: Container(
height: MediaQuery.of(context).size.height - 300.0,
child: ListView(
children: [
buildInvoice(
'Rent one month', 'July rent', '800€')
],
)))
])),
Expanded(
child: ButtonsDetailInvoice(),
),
],
),
);
}
按钮小部件中的代码:
return Container(
height: 450.0,
// margin: const EdgeInsets.all(20.0),
child: Row(
children: [
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: colorBlau)),
onPressed: () {},
color: colorBlau,
textColor: Colors.white,
child: Row(
children: <Widget>[
Icon(Icons.file_download),
Text('Download', style: TextStyle(fontSize: 15.0))
],
),
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: colorMint)),
onPressed: () {},
color: colorMint,
textColor: Colors.white,
child: Row(
children: <Widget>[
Icon(Icons.share),
Text('Share', style: TextStyle(fontSize: 15.0))
],
),
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: colorRed)),
onPressed: () {},
color: colorRed,
textColor: Colors.white,
child: Text('Report a Problem', style: TextStyle(fontSize: 15.0)),
),
],
),
);
}
}
我想看看主文件底部的按钮。我导入了它们,但它们没有显示。如果有人可以帮助查看错误,我将不胜感激。
解决方案
在主文件中使用 Stack 小部件。
推荐阅读
- docker - Apache Airflow:如何使用来自另一个任务的环境变量运行 Docker Operator?
- python - 我的帕斯卡三角程序中这个神秘数字是从哪里来的?
- javascript - 如何禁用 html 范围滑块?
- indexeddb - svelte.dev/repl 似乎不支持 indexedDb(或 localStorage)
- swift - textField 最大长度和邮政编码验证
- javascript - 在 VBA 中使用脚本时出错
- c++ - 计算与异常二维空间中点的角度的函数
- azure - 在 Azure 中,使用 powershell 脚本将负载均衡器详细信息保存到 csv 文件中
- reactjs - Highcharts addPoint 动画
- python - 如何使用python在json文件中查找不完整的数据