【发布时间】:2021-11-19 07:54:18
【问题描述】:
我有一个 Column 小部件,它有 2 个孩子:一个 SizedBox 和一个带有 Text 小部件的 Container。我在 iOS 模拟器中出现溢出,但它在 Android 上呈现没有问题。我应该使用 MediaQuery 根据设备类型自定义 SizedBox 高度吗? (注意:包含 Scaffold/Stack 代码只是为了提供更多上下文,并且可能与溢出问题无关,除非我弄错了!)
Widget build(BuildContext context) {
return new Scaffold(
body: new Swiper(
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onVerticalDragStart: (details) {
/* do something */
));
},
child: Stack(
children: [
ShaderMask(
shaderCallback: (Rect bounds) {
return LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.center,
colors: [Colors.black12, Colors.white])
.createShader(bounds);
},
child: Container(
padding:
new EdgeInsets.only(left: 16.0, bottom: 8.0, right: 16.0),
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage(tipList[index].imagePath),
fit: BoxFit.cover,
),
),
),
),
Column(
children: [
new SizedBox(height: 700),
Container(
padding: new EdgeInsets.only(left: 16.0, bottom: 8.0, right: 16.0),
child: new Text(tipList[index].description,
style: Theme.of(context).textTheme.headline4),
),
],
),
],
),
【问题讨论】: