[英]Flutter: single child scroll view is not working within positioned widget
[Here is an image of the component that I am trying to make scrollable][1]The single child scroll view widget is not properly scrolling when I wrap it within a positioned widget. [这是我试图使其可滚动的组件的图像][1]当我将单个子滚动视图小部件包装在定位的小部件中时,它没有正确滚动。 I need to have the positioned widget in order to properly align my components.我需要有定位的小部件才能正确对齐我的组件。 How can I solve this issue?我该如何解决这个问题?
Container(
height: 130,
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey[800],
borderRadius: const BorderRadius.all(const Radius.circular(10)),
),
child: Stack(
children: [
Positioned(
top: 30,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ProfilePicScroll(),
),
),
Positioned(
left: 10,
child: Text(
'Following',
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
)),
[1]: https://i.stack.imgur.com/pMPxZ.png
change your Positioned
widget to Padding
.将您的Positioned
小部件更改为Padding
。
Stack(
children: [
Padding(
padding: const EdgeInsets.only(top: 30.0),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ProfilePicScroll(),
),
),
const Positioned(
left: 10,
child: Text(
'Following',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
],
)
get all Positioned
arguments a value.获取所有Positioned
的 arguments 一个值。
Stack(
children: [
Positioned(
top: 30,
left: 0,
right: 0,
bottom: 0,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ProfilePicScroll(),
),
),
const Positioned(
left: 10,
child: Text(
'Following',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
],
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.