我有两个屏幕,第一个从 wordpress 获取所有帖子,最后一个获取所有视频,我使用带有 ListView 的 ScollController 滚动数据
看看我的代码:
ScrollController _scrollController;
@override
void initState() {
_scrollController = new ScrollController();
_scrollController.addListener(() {
print(_scrollController.position.pixels);
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent - 10) {
// if we are the bottom of the page
fetchPosts();
//millisecs += 1500;
//super.initState();
}
super.initState();
});
}
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) { ....
Run Code Online (Sandbox Code Playgroud)
当我在屏幕一到两个或屏幕二到一之间切换时
我收到此错误:
Exception has occurred.
FlutterError (A ScrollController was used after being disposed.
Once you have called dispose() on a ScrollController, it can no longer be used.)
Run Code Online (Sandbox Code Playgroud)
跟踪代码: 图像错误
Launching lib\main.dart on Android SDK built for x86 in debug mode... Built build\app\outputs\apk\debug\app-debug.apk. D/EGL_emulation( 8157): eglMakeCurrent: 0xeeebd340: ver 3 1 (tinfo 0xeee9b1d0) E/eglCodecCommon( 8157): glUtilsParamSize: unknow param 0x000082da E/eglCodecCommon( 8157): glUtilsParamSize: unknow param 0x000082da I/Choreographer( 8157): Skipped 49 frames! The application may be doing too much work on its main thread. D/EGL_emulation( 8157): eglMakeCurrent: 0xeef21ce0: ver 3 1 (tinfo 0xe6f286b0) D/ ( 8157): HostConnection::get() New Host Connection established 0xe7123880, tid 8184 D/EGL_emulation( 8157): eglMakeCurrent: 0xeeebd340: ver 3 1 (tinfo 0xe7103370) I/flutter ( 8157): _morePages: false I/flutter ( 8157): statusCode: 200 I/flutter ( 8157): ??? EXCEPTION CAUGHT BY FOUNDATION LIBRARY ????????????????????????????????????????????????????????? I/flutter ( 8157): The following assertion was thrown while dispatching notifications for ScrollController: I/flutter ( 8157): 'package:flutter/src/widgets/framework.dart': Failed assertion: line 1003 pos 12: I/flutter ( 8157): '_debugLifecycleState == _StateLifecycle.created': is not true. I/flutter ( 8157): I/flutter ( 8157): Either the assertion indicates an error in the framework itself, or we should provide substantially I/flutter ( 8157): more information in this error message to help you determine and fix the underlying cause. I/flutter ( 8157): In either case, please report this assertion by filing a bug on GitHub: I/flutter ( 8157): https://github.com/flutter/flutter/issues/new?template=BUG.md I/flutter ( 8157): I/flutter ( 8157): 当抛出异常时,这是堆栈: I/flutter ( 8157): #2 State.initState (package:flutter/src/widgets/framework.dart: 1003:12) I/flutter (8157):#3 _PostsPage.initState。(package:flutter_wp2019/ui/PostsLatest.dart:42:13) I/flutter (8157): #4 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:208:21) I/flutter (8157) : #5 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:208:21) I/flutter (8157): #6 ScrollPosition.notifyListeners (package:flutter/src/widgets/scroll_position.dart:692: 11) I/flutter (8157): #7 ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:218:9) I/flutter (8157): #8 ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18) I/flutter (8157): #9 ScrollPositionWithSingleContext.applyUserOffset (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18) ) I/flutter (8157): #10 ScrollDragController.update (package:flutter/src/widgets/scroll_activity.dart:373:14) I/flutter (8157): #11 ScrollableState._handleDragUpdate (package:flutter/src/widgets/scroll_activity.dart:373:14) /scrollable.dart:470:12) I/flutter (8157): #12 DragGestureRecognizer.acceptGesture。(package:flutter/src/gestures/monodrag.dart:176:48) I/flutter (8157): #13 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24) I/flutter ( 8157):#14 DragGestureRecognizer.acceptGesture(包:ui/hooks.dart:168:13) I/flutter (8157): #28 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5) I/flutter (8157):(从 _AssertionError 类中删除了 2 帧)I/ flutter ( 8157): I/flutter ( 8157): ScrollController 发送通知是: I/flutter ( 8157): ScrollController#bcc47(one client, offset 21.4) I/flutter (8157): ???????? ?????????????????????????????????????????????????????? ????????????????????????????????????????????? I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created': is not true。I/chatty (8157): uid=10083(com.example.flutterwp2019) 1.ui 相同 16 行 I/flutter (8157): 抛出另一个异常:'package: flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created': 不是真的。I/zygote(8157):做部分代码缓存收集,代码=29KB,数据=23KB I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':失败的断言:行1003 pos 12: '_debugLifecycleState == _StateLifecycle.created': 不是真的。I/chatty (8157): uid=10083(com.example.flutterwp2019) 1.ui 相同 1 行 I/flutter (8157): 抛出另一个异常:'package:flutter/src/widgets/framework.dart': Failed断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。I/zygote(8157):代码缓存收集后,code=29KB,data=23KB I/zygote(8157):将代码缓存容量增加到 128KB I/flutter (8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':失败的断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':是不对。I/chatty (8157): uid=10083(com.example.flutterwp2019) 1.ui 相同 11 行 I/flutter (8157): 抛出另一个异常:'package:flutter/src/widgets/framework.dart': Failed断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。I/zygote(8157):做部分代码缓存采集,code=59KB,data=40KB I/zygote(8157):代码缓存采集后,code=59KB,data=40KB I/zygote(8157):增加代码缓存容量到 256KB I/颤振(8157):30.00837053571422 I/颤振(8157):抛出了另一个异常:'package:flutter/src/widgets/framework.dart': Failed assertion: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created': is not true。I/flutter (8157): 42.86551339285711 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart': 失败的断言:line 1003 pos 12: '_debugLifecycleState. == _State : 不是真的。I/flutter (8157): 55.72265625 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created' : 不是真的。I/flutter (8157): 71.41741071428567 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework. dart':失败的断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。I/flutter (8157): 88.56863839285711 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugLifecycleState.=='State : 不是真的。I/flutter(8157):105.71986607142856 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.==' : 不是真的。I/flutter(8157):120.24285714285713 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行pos 12:' _debugLifecycleState == _StateLifecycle.created': 不是真的。I/flutter(8157):117.38013392857141 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.==' : 不是真的。I/flutter(8157):110.24843749999997 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.==' : 不是真的。I/flutter (8157): 93.09720982142858 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart': 失败的断言:line 1003 pos 12: '_debugLifecycleState. == _State :不是真的。I/flutter (8157): 63.0888392857143 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugLifecycleState. == _StateLifecycleState : 不是真的。I/flutter (8157): 23.11116071428569 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart': 失败的断言:line 1003 pos 12: '_debugLifecycleState. == _State : 不是真的。I/flutter (8157): 0.0 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created' : 不是真的。我/颤振(8157):1。4313616071428896 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugLifecycleState == _StateLifecycle.created':不是真的。I/flutter (8157): 8.58816964285711 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState. == _StateLifecycleState : 不是真的。I/flutter(8157):24.006696428571445 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.==' : 不是真的。I/颤振(8157):41.15792410714289 I/颤振(8157):抛出了另一个异常:'package:flutter/src/widgets/framework.dart': Failed assertion: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created': is not true。I/flutter (8157): 64.00948660714289 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugLifecycleState.=='State : 不是真的。I/flutter (8157): 85.4296875 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created' : 不是真的。I/flutter (8157): 108.28125 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart' :失败的断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。I/flutter (8157): 120.24285714285713 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugStateLifecycleState. == _create_dart : 不是真的。I/flutter(8157):2.8376116071428896 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.==' : 不是真的。I/flutter(8157):7.131696428571445 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行pos 12:' _debugLifecycleState == _StateLifecycle.created': 不是真的。I/flutter (8157): 11.42578125 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created' : 不是真的。I/flutter(8157):18.557477678571445 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.=='created : 不是真的。I/flutter (8157): 24.28292410714289 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugLifecycleState. == _State : 不是真的。I/flutter(8157):39.977678571428555 I/flutter(8157):抛出另一个异常:'package:flutter/src/widgets/framework.dart':断言失败:第1003行位置12:'_debugStateLifecycleState.==' : 不是真的。I/flutter (8157): 57.12890625 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created' : 不是真的。I/flutter (8157): 77.14285714285717 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugLifecycleState.=='State : 不是真的。I/颤振(8157):97.13169642857144 I/颤振(8157):抛出了另一个异常:'package:flutter/src/widgets/framework.dart': Failed assertion: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle.created': is not true。I/flutter (8157): 115.71428571428572 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart': 失败的断言:line 1003 pos 12: '_debugStateLifecycleState. == _create_dart : 不是真的。I/flutter (8157): 120.24285714285713 I/flutter (8157): 另一个异常被抛出:'package:flutter/src/widgets/framework.dart':失败的断言:line 1003 pos 12:'_debugStateLifecycleState. == _create_dart : 不是真的。I/flutter (8157): _morePages: false I/flutter (8157): statusCode: 200 I/flutter (8157): _morePages: false I/flutter (8157): statusCode: 400 I/flutter (8157): 另一个异常被抛出: 'package:flutter/src/widgets/framework.dart': 失败的断言: line 1003 pos 12: '_debugLifecycleState == _StateLifecycle .created': 不是真的。I/chatty (8157): uid=10083(com.example.flutterwp2019) 1.ui 相同 22 行 I/flutter (8157): 抛出另一个异常:'package:flutter/src/widgets/framework.dart': Failed断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。我/颤振(8157):_morePages:假我/颤振(8157):状态代码:200 _debugLifecycleState == _StateLifecycle.created': 不是真的。I/chatty (8157): uid=10083(com.example.flutterwp2019) 1.ui 相同 22 行 I/flutter (8157): 抛出另一个异常:'package:flutter/src/widgets/framework.dart': Failed断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。我/颤振(8157):_morePages:假我/颤振(8157):状态代码:200 _debugLifecycleState == _StateLifecycle.created': 不是真的。I/chatty (8157): uid=10083(com.example.flutterwp2019) 1.ui 相同 22 行 I/flutter (8157): 抛出另一个异常:'package:flutter/src/widgets/framework.dart': Failed断言:第 1003 行 pos 12:'_debugLifecycleState == _StateLifecycle.created':不是真的。我/颤振(8157):_morePages:假我/颤振(8157):状态代码:200
感谢提前
super.initState() 在错误的位置
@override
void initState() {
super.initState(); // <<< added
_scrollController = new ScrollController();
_scrollController.addListener(() {
print(_scrollController.position.pixels);
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent - 10) {
// if we are the bottom of the page
fetchPosts();
//millisecs += 1500;
//super.initState();
}
// super.initState(); // <<< removed
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6462 次 |
| 最近记录: |