【发布时间】:2020-12-14 07:30:01
【问题描述】:
下面的代码
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
home: const MyHomePage(),
);
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) => DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: const Center(
child: Text('use the mouse wheel to scroll')),
bottom: TabBar(
tabs: const [
Center(child: Text('ScrollView')),
Center(child: Text('PageView'))
],
),
),
body: TabBarView(
children: [
SingleChildScrollView(
child: Column(
children: [
for (int i = 0; i < 10; i++)
Container(
height: MediaQuery.of(context).size.height,
child: const Center(
child: FlutterLogo(size: 80),
),
),
],
),
),
PageView(
scrollDirection: Axis.vertical,
children: [
for (int i = 0; i < 10; ++i)
const Center(
child: FlutterLogo(size: 80),
),
],
),
],
),
),
);
}
您可以看到,在dartpad 或从这个video 上运行它,
使用鼠标滚轮滚动PageView 提供平庸的体验(充其量),
这是一个已知问题#35687#32120,但我正在尝试寻找解决方法
实现PageView 的平滑滚动或至少防止“卡顿”。
有人可以帮助我或指出正确的方向吗?
我不确定问题出在PageScrollPhysics;
我有一种直觉认为问题可能出在WheelEvent
因为使用多点触控滚动滑动效果很好
【问题讨论】:
标签: flutter flutter-web mousewheel smooth-scrolling flutter-pageview