android - Flutter:当我滚动到 NESTED ListView 的末尾时,我希望父 ListView 滚动
问题描述
以下代码实现了一个带有嵌套 ListView 作为子级之一的 ListView。
Web 构建的行为:当我向下滚动到嵌套 ListView 的底部时,它会导致父级滚动。
Android 构建的行为:当我向下滚动到嵌套 ListView 的底部时,它不会导致父级滚动。
为什么有区别?如何使 Android 构建的行为类似于 Web 构建?
谢谢
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Demo')),
// body: CollapsingList(),
body: NestedLists(),
),
);
}
}
class NestedLists extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView(
children: [
Container(color: Colors.red, height: 150.0),
Container(color: Colors.purple, height: 150.0),
Container(color: Colors.green, height: 150.0),
Container(color: Colors.orange, height: 150.0),
Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
height: 150,
child: ListView(
children: [
Container(color: Colors.yellow, height: 50.0),
Container(color: Colors.pink, height: 50.0),
Container(color: Colors.cyan, height: 50.0),
Container(color: Colors.indigo, height: 50.0),
Container(color: Colors.blue, height: 50.0),
Container(color: Colors.yellow, height: 50.0),
Container(color: Colors.pink, height: 50.0),
Container(color: Colors.cyan, height: 50.0),
Container(color: Colors.indigo, height: 50.0),
Container(color: Colors.blue, height: 50.0),
Container(color: Colors.yellow, height: 50.0),
],
),
),
),
Container(color: Colors.yellow, height: 150.0),
Container(color: Colors.pink, height: 150.0),
Container(color: Colors.cyan, height: 150.0),
Container(color: Colors.indigo, height: 150.0),
Container(color: Colors.blue, height: 150.0),
],
);
}
}
解决方案
推荐阅读
- python - Python/GTK3:如何在销毁时保持窗口打开?
- java - 如何在groovy应用中升级http协议TLS1.2
- android - java.lang.StackOverflowError:堆栈大小 8MB:Aftertextchanged
- vb.net - 使用文本框的数据网格过滤器
- wildfly - WildFly 启动时随机加载模块失败
- ruby-on-rails - will_paginate 方法有问题
- youtube-data-api - 想不通,为什么我得到一个 403
- javascript - 将弹出窗口绑定到折线以在反应传单中出现 onMouseover
- docker - 如何从主机检查 docker 容器中是否存在文件夹
- python - 适用于 Python 的 Docker SDK:fileobj