我有一个 SingleChildScrollView 作为其父 SingleChildScrollView 小部件内的子小部件,如下图所示,
当前,当我向下滚动内部滚动视图中的触摸区域时,内部滚动视图向下滚动并且到达底部时没有任何移动。
但我希望当内部滚动视图到达底部时整个屏幕(外部滚动视图)开始滚动,如下所示。 (如果我必须再次点击才能滚动外部滚动视图也没关系)
我怎样才能实现这种行为?
编辑
请参阅下面我的代码:
class ExampleState extends State<Example> {
String title = "text text text text texwtxtwtwxtx wtxwtxwtwtxt";
String description = "textexxtett t exte tx tetexxt text text text";
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height * 0.15,
maxHeight: MediaQuery.of(context).size.height * 0.30,
),
child: Container(
padding: EdgeInsets.fromLTRB(25, 0, 25, 25),
child: SingleChildScrollView(child: Column(
children: [
Text("$title\n"),
Text("$description")
]))))]))));}},
这对我有用。
return ListView(
controller: _controller,
children: [
Placeholder(fallbackHeight: 400),
Placeholder(fallbackHeight: 400),
Placeholder(fallbackHeight: 400),
Container(
padding: EdgeInsets.symmetric(horizontal: 20),
height: 400,
child: NotificationListener(
onNotification: (OverscrollNotification notification) {
final dy = notification.overscroll;
_controller.position.jumpTo(_controller.offset + dy);
return true;
},
child: ListView(
children: [
Placeholder(fallbackHeight: 200),
Placeholder(fallbackHeight: 200),
Placeholder(fallbackHeight: 200),
Placeholder(fallbackHeight: 200),
],
),
),
)
],
);