如何在颤振中实现"Instagram相机"滚动?



我正在尝试使用页面视图中的滚动视图在颤振中实现此效果:

https://ibb.co/dMd3TZL

但是当我滚动到第二页时,我卡住了,我再也回不去了。

示例代码:

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: Text("Demo"),
),
body: PageView(
scrollDirection: Axis.vertical,
children:[
Container(color: Colors.red),
ListView(
children:[
Container(color: Colors.yellow, height:300),
Container(color: Colors.green, height:300),
]
)
],
),
),
);
}
}

当滚动视图到达末尾时,如何将onDrag事件发送到页面视图?

列表视图不适用于页面查看器,因此请使用wrap Widget而不是listview,如下所示,

PageView(
scrollDirection: Axis.vertical,
children:[
Container(color: Colors.red),
Wrap(
children:[
Container(color: Colors.yellow, height:300),
Container(color: Colors.green, height:300),
]
)
],
),

最新更新