作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用SingleChildScrollView
作为其第一个元素的Stack
。 Stack
包含两个容器。第二个使用bottom: 0.0
定位在Positioned
。
我高度简化了对本文的观点,使其仅关注此问题。当我缓慢滚动时,您会看到白色容器正在“闪烁”,并且您看到的一行是堆栈中第一个子容器的底部。
这是 View :
向下滚动时不会发生这种情况,我不知道为什么会出现这样的故障:
View :
return Container(color: Colors.white, child: SingleChildScrollView(child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
HeaderComponent(),
Container(height: 600, width: MediaQuery.of(context).size.width)
]
)));
class _HeaderComponentState extends State<HeaderComponent> {
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(height: 245.0, width: MediaQuery.of(context).size.width, color: Colors.red),
Positioned(bottom: 0.0, child: Container(height: 40.0, width:
MediaQuery.of(context).size.width, color: Colors.white)),
],
);
}
}
最佳答案
如果是这样,只需在第一个 child 处添加底部填充0.2。
class HeaderComponent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(
height: 245.0,
padding: EdgeInsets.only(bottom: 0.2),
width: MediaQuery.of(context).size.width,
color: Colors.red),
Positioned(
bottom: 0.0,
child: Container(
height: 40.0,
width: MediaQuery.of(context).size.width,
color: Colors.white)),
],
);
}
}
关于flutter - Flutter SingledChildScrollView>堆栈>定位为滚动上的故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62440501/
我正在使用SingleChildScrollView作为其第一个元素的Stack。 Stack包含两个容器。第二个使用bottom: 0.0定位在Positioned。 我高度简化了对本文的观点,使其
我是一名优秀的程序员,十分优秀!