flutter - 堆栈小部件在 SCSV、颤振中不滚动
问题描述
我在小部件之上使用一对一小Stack
部件,但我遇到的问题是我的整个 Stack 小部件无法滚动以查看全部内容。我用a 包裹了小部件,但问题仍然存在。如果我用 a 包装 Stack 小部件并使其可滚动,但我仍然看不到页面的全部内容。我的错误在哪里,这就是我想知道的?我应该用什么小部件来包装 Stack 还是有更好的方法来解决我的问题?简而言之,我将 a 堆叠在 an 之上,并且我需要整个小部件是可滚动的,这样我才能看到 Stack 小部件的全部内容。这是代码:Positioned
Image.asset
Stack
SingleChildScrollView
Containter
height: MediaQuery.of(context).size.height,
Column
Image
Stack
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
body: SafeArea(
child: SingleChildScrollView(
child: Stack(
overflow: Overflow.visible,
children: [
Image.asset(
'lib/modules/common/images/logo.png',
width: double.infinity,
height: 196.0,
),
Positioned(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
top: 136.0,
child: Column(
children: [
Container(), // some content inside the container
Container(), // // some content inside the container
],
),
),
],
),
),
),
);
}
在此先感谢您的帮助!
解决方案
如果你的意思是在背面有一个图像和可滚动的内容,请检查这个答案,如果不是让我知道并分享你想要的原型/图像。
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
body: SafeArea(
child: SingleChildScrollView(
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 3,
child: Stack(
fit: StackFit.loose,
children: [
Align(
alignment: Alignment.topCenter,
child: Image.asset(
'assets/image.jpg',
width: double.infinity,
height: 196.0,
),
),
Positioned(
top: 136.0,
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Column(
mainAxisSize: MainAxisSize.min,
children: List.generate(
2,
(index) => Container(
height: 100,
width: double.infinity,
color: index % 2 == 0
? Colors.amberAccent
: Colors.cyanAccent,
), // some content inside the container
// some content inside the container
),
),
),
),
],
),
),
),
),
);
}
推荐阅读
- python - Firebase Cloud Function 在将数据发送到 Pub/Sub 主题时创建错误消息
- ios - 如何在演示期间更改 ViewController 的 NavigationBar 动画方式
- flutter - 如何在 Flutter web 中隐藏“Bearer token”?
- javascript - 为什么不一样?(JS)
- postgresql - 在 PostgresSql 中,如何删除值包含撇号的行?
- ethereum - 如何区分ERC20和ERC721?
- javascript - 为什么我无法输出元素的控制台信息?
- python - 如何修复我的 pyinstaller .exe 找不到 matplotlib 文件的错误?
- c - 如何在 C 中使用 strtok 将 C 字符串拆分两次?
- css - 材质 UI DatePickerRange