【发布时间】:2019-10-22 00:32:58
【问题描述】:
我正在学习 Flutter,所以如果我的问题是一个愚蠢的问题,请不要向我扔石头 :p :D
首先,下面的一些图片你可能很熟悉,我只是使用这个来自 github 的应用程序来测试理论。来源:https://www.youtube.com/watch?v=sgfMdhV4HQI&t=370s
我的问题:
我正在使用综合浏览量在两个页面之间导航,一个具有一些可拖动容器,另一个页面具有一些代表不同主题的更多可拖动容器。
如果我定义 scrollDirection: Axis.horizontal, 它可以正常工作。但我想垂直拖动它。
如果我定义 scrollDirection: Axis.vertical, 我意识到,我只有一小部分屏幕可以拖动页面。
据我了解,可能与容器有关。
- 如何在触摸屏幕上任意位置的同时垂直拖动?
注意:我还测试了 SliverToBoxAdapter 类,但没有得到很好的结果。
我的 git repro https://github.com/engineerRFR/flutter-mytest
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Netflix UI Redesign',
debugShowCheckedModeBanner: false,
home: PageView(
children: <Widget>[
Container(
color: Colors.pink,
child: HomeScreen(),
),
Container(
color: Colors.cyan,
child: photoGallery(),
),
Container(
color: Colors.deepPurple,
),
],
scrollDirection: Axis.horizontal,
onPageChanged: (num) {
print("Page number : " + num.toString());
},
),
);
}
}
photoGallery (){
return PageView(
scrollDirection: Axis.vertical,
children: <Widget>[
Container(
color: Colors.amber,
)
,
【问题讨论】:
-
我创建了同一个项目,它使用您提供的代码开箱即用,我能够从页面上的任何位置拖动和滚动。也许您从 Github 中提取的应用程序中还有其他影响触摸/手势的东西?
-
你好 Dusk,我也是从 git 下载的,并添加了 pageView 和 photoGallery() 以显示在第二个屏幕上。
-
能分享一下git项目吗?
-
今晚我将创建 git。 :)
-
我的 git repro github.com/engineerRFR/flutter-mytest