flutter - 如何在颤动中实现“instagram 相机”滚动?
问题描述
我正在尝试在 PageView 中使用 ScrollView 来实现这种效果:
但是当我滚动到第二页时,我被卡住了,我不能再回去了。
示例代码:
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),
]
)
],
),
),
);
}
}
当 ScrollView 到达末尾时,如何将 onDrag 事件发送到 PageView?
解决方案
listview 不适用于 pageviewer,因此请使用 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),
]
)
],
),
推荐阅读
- r - R mutate and map: 传递链接到 .?
- linux - 在 Linux 上获取 Common Lisp 进程 ID
- algorithm - 设置位计数
- python - Perl 的 -Sx 命令行选项的 Pythonic 等效项是什么?
- php - 有没有办法根据对象的位置 Amazon S3、PHP SDK 获取嵌套的对象数组?
- java - Android Room BitMap Image ImageView 从数据库中获取时是模糊的
- typescript - 扩展索引打字稿接口
- javascript - 使用 forEach 和 axios 进行异步/等待
- spring - 如果我在两个地方自动接线,它会构造两次吗?
- jquery - 我需要使用 JQuery 和 Vue.js 打开像手风琴一样的 DIV