pullToRefresh在pc和web上的兼容问题
# pullToRefresh在pc和web上的兼容问题
# 如何支持web和pc
pullToRefresh库只支持客户端,如何支持web和pc呢?
参考这个问题:
web和mac上,无法用鼠标滚轮滑动 (opens new window)
Widget wrapIfWebOrMacOs(Widget buildRefreshLoadMoreList,context) {
if(PlatformType.isWeb() || PlatformType.isWebInMobile() || PlatformType.isDesktop()){
return ImprovedScrolling(
scrollController: logic.macAndWebScrollController,
enableCustomMouseWheelScrolling: true,
child: ScrollConfiguration(
behavior:
ScrollConfiguration.of(context).copyWith(dragDevices: PointerDeviceKind.values.toSet()),
child: buildRefreshLoadMoreList
));
}else{
return buildRefreshLoadMoreList;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# web运行时:
--web-renderer canvaskit 时,下拉刷新正常
--web-renderer html 时,下拉报错:
PersistedOffset: is in an unexpected state.
Expected one of: PersistedSurfaceState.active, PersistedSurfaceState.released
But was: PersistedSurfaceState.created
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_
lib/_engine/engine/html/surface.dart 179:3 debugAssertSurfaceState
lib/_engine/engine/html/scene_builder.dart 295:14 addRetained
packages/flutter/src/rendering/layer.dart 668:14 [_addToSceneWithRetainedRendering]
...
packages/flutter/src/widgets/binding.dart 865:13 drawFrame
packages/flutter/src/rendering/binding.dart 381:5 [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1289:15 [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1218:9 handleDrawFrame
packages/flutter/src/scheduler/binding.dart 1076:5 [_handleDrawFrame]
dart-sdk/lib/async/zone.dart 1398:13 _rootRun
dart-sdk/lib/async/zone.dart 1300:19 run
dart-sdk/lib/async/zone.dart 1208:7 runGuarded
lib/_engine/engine/platform_dispatcher.dart 1170:9 invoke
lib/_engine/engine/platform_dispatcher.dart 218:5 invokeOnDrawFrame
lib/_engine/engine/initialization.dart 190:45 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39 dcall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
将以上错误代码输入chatgpt,得到的答复是:
This error may indicate that there is an issue with managing the state of a PersistedSurface object, such as creating or releasing the object at the wrong time. To fix this issue, the code should be reviewed to ensure that the PersistedSurface object is being created and released properly and that it is in the expected state when being used.
翻译后为:
这个错误可能表示PersistedSurface对象的状态管理存在问题,例如在错误的时间创建或释放对象。要解决这个问题,应当检查代码以确保正确创建和释放PersistedSurface对象,并在使用时它处于预期的状态。
并非scrollController的问题,而是头部的lottie动画的问题
替换头部为WaterDropHeader就正常了
编辑 (opens new window)
上次更新: 2023/05/09, 17:55:07