IOS status bar tap fails scroll to the top
I am using this package.
The package is a widget provided to the flutter scroll component drop-down refresh and pull up load.support android and ios
The package url is https://pub.dartlang.org/packages/pull_to_refresh
But this package has a bug !
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Example1 extends StatefulWidget {
@override
_Example1State createState() => new _Example1State();
}
class _Example1State extends State<Example1> {
// RefreshMode refreshing = RefreshMode.idle;
// LoadMode loading = LoadMode.idle;
RefreshController _refreshController;
List<Widget> data = ;
void _getDatas() {
for (int i = 0; i < 14; i++) {
data.add(new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data $i'),
),
));
}
}
void enterRefresh() {
_refreshController.requestRefresh(true);
}
void _onOffsetCallback(bool isUp, double offset) {
// if you want change some widgets state ,you should rewrite the callback
}
@override
void initState() {
// TODO: implement initState
_getDatas();
_refreshController = new RefreshController();
super.initState();
}
Widget _headerCreate(BuildContext context, int mode) {
return new ClassicIndicator(
mode: mode,
refreshingText: "",
idleIcon: new Container(),
idleText: "Load more...",
);
}
// Widget _footerCreate(BuildContext context,int mode){
// return new ClassicIndicator(mode: mode);
// }
@override
Widget build(BuildContext context) {
return new Container(
child: new SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: _refreshController,
onRefresh: (up) {
if (up)
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
_refreshController.scrollTo(_refreshController.scrollController.offset+100.0);
_refreshController.sendBack(true, RefreshStatus.idle);
setState(() {});
// refresher.sendStatus(RefreshStatus.completed);
});
else {
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
setState(() {});
_refreshController.sendBack(false, RefreshStatus.idle);
});
}
},
onOffsetChange: _onOffsetCallback,
child: new ListView.builder(
reverse: true,
itemExtent: 100.0,
itemCount: data.length,
itemBuilder: (context, index) => new Item(),
)));
}
}
class Item extends StatefulWidget {
@override
_ItemState createState() => new _ItemState();
}
class _ItemState extends State<Item> {
@override
Widget build(BuildContext context) {
return new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data'),
),
);
}
@override
void dispose() {
// TODO: implement dispose
print("销毁");
super.dispose();
}
}
When I tap the status bar,can't scroll to the top!
I tried to debug this package, I found that in line 344 of the smart_refresher.dart file, just comment the controller property and scroll back to the top, like this
But the pull-down refresh action will give an error.
flutter: ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown while notifying listeners for AnimationController:
flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12:
flutter: '_positions.isNotEmpty'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
flutter: #3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
flutter: #4 _SmartRefresherState._buildWrapperByConfig.<anonymous closure> (package:pull_to_refresh/src/smart_refresher.dart:291:42)
flutter: #5 RefreshWrapperState._handleOffsetCallBack (package:pull_to_refresh/src/internals/indicator_wrap.dart:163:14)
flutter: #6 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #7 AnimationController.value= (package:flutter/src/animation/animation_controller.dart:351:5)
flutter: #8 RefreshWrapperState._handleModeChange (package:pull_to_refresh/src/internals/indicator_wrap.dart:171:25)
flutter: #9 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:208:21)
flutter: #10 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:264:5)
flutter: #11 Wrapper.mode= (package:pull_to_refresh/src/internals/indicator_wrap.dart:31:43)
flutter: #12 RefreshWrapperState.onDragEnd (package:pull_to_refresh/src/internals/indicator_wrap.dart:157:14)
flutter: #13 _SmartRefresherState._handleScrollEnd (package:pull_to_refresh/src/smart_refresher.dart:120:40)
flutter: #14 _SmartRefresherState._dispatchScrollEvent (package:pull_to_refresh/src/smart_refresher.dart:133:16)
flutter: #15 NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:125:27)
flutter: #16 Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:45:20)
flutter: #17 _ScrollNotification&LayoutChangedNotification&ViewportNotificationMixin.visitAncestor (package:flutter/src/widgets/scroll_notification.dart:31:18)
flutter: #18 Element.visitAncestorElements (package:flutter/src/widgets/framework.dart:3344:39)
flutter: #19 Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:59:12)
flutter: #20 ScrollActivity.dispatchScrollUpdateNotification (package:flutter/src/widgets/scroll_activity.dart:96:92)
flutter: #21 ScrollPosition.didUpdateScrollPositionBy (package:flutter/src/widgets/scroll_position.dart:654:14)
flutter: #22 ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:219:9)
flutter: #23 ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18)
flutter: #24 BallisticScrollActivity.applyMoveTo (package:flutter/src/widgets/scroll_activity.dart:547:21)
flutter: #25 BallisticScrollActivity._tick (package:flutter/src/widgets/scroll_activity.dart:534:10)
flutter: #26 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #27 AnimationController._tick (package:flutter/src/animation/animation_controller.dart:697:5)
flutter: #28 Ticker._tick (package:flutter/src/scheduler/ticker.dart:228:5)
flutter: #29 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #30 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
flutter: #31 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
flutter: #32 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
flutter: #33 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:834:5)
flutter: #34 _invoke1 (dart:ui/hooks.dart:168:13)
flutter: #35 _beginFrame (dart:ui/hooks.dart:138:3)
flutter: (elided 2 frames from class _AssertionError)
flutter:
flutter: The AnimationController notifying listeners was:
flutter: AnimationController#96484(⏭ 1.000; paused)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: ScrollController not attached to any scroll views.
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
#0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
#1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
#2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
#3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
#4 _Example1State.build.<anonymous closure>.<anonymous closure> (package:example/ui/Example1.dart:76:83)
#5 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#8 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#9 Future._complete (dart:as<…>
Relevant doctor info:
[✓] Flutter (Channel dev, v0.11.6, on Mac OS X 10.13.6 17G65, locale
zh-Hans-CN) [✓] Android toolchain - develop for Android devices
(Android SDK 28.0.3) [✓] iOS toolchain - develop for iOS devices
(Xcode 10.1) [✓] Android Studio (version 3.2)
[✓] VS Code (version> 1.29.1)
[✓] Connected device (1 available)
Please help me solve this bug, thank you.
dart package flutter
add a comment |
I am using this package.
The package is a widget provided to the flutter scroll component drop-down refresh and pull up load.support android and ios
The package url is https://pub.dartlang.org/packages/pull_to_refresh
But this package has a bug !
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Example1 extends StatefulWidget {
@override
_Example1State createState() => new _Example1State();
}
class _Example1State extends State<Example1> {
// RefreshMode refreshing = RefreshMode.idle;
// LoadMode loading = LoadMode.idle;
RefreshController _refreshController;
List<Widget> data = ;
void _getDatas() {
for (int i = 0; i < 14; i++) {
data.add(new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data $i'),
),
));
}
}
void enterRefresh() {
_refreshController.requestRefresh(true);
}
void _onOffsetCallback(bool isUp, double offset) {
// if you want change some widgets state ,you should rewrite the callback
}
@override
void initState() {
// TODO: implement initState
_getDatas();
_refreshController = new RefreshController();
super.initState();
}
Widget _headerCreate(BuildContext context, int mode) {
return new ClassicIndicator(
mode: mode,
refreshingText: "",
idleIcon: new Container(),
idleText: "Load more...",
);
}
// Widget _footerCreate(BuildContext context,int mode){
// return new ClassicIndicator(mode: mode);
// }
@override
Widget build(BuildContext context) {
return new Container(
child: new SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: _refreshController,
onRefresh: (up) {
if (up)
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
_refreshController.scrollTo(_refreshController.scrollController.offset+100.0);
_refreshController.sendBack(true, RefreshStatus.idle);
setState(() {});
// refresher.sendStatus(RefreshStatus.completed);
});
else {
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
setState(() {});
_refreshController.sendBack(false, RefreshStatus.idle);
});
}
},
onOffsetChange: _onOffsetCallback,
child: new ListView.builder(
reverse: true,
itemExtent: 100.0,
itemCount: data.length,
itemBuilder: (context, index) => new Item(),
)));
}
}
class Item extends StatefulWidget {
@override
_ItemState createState() => new _ItemState();
}
class _ItemState extends State<Item> {
@override
Widget build(BuildContext context) {
return new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data'),
),
);
}
@override
void dispose() {
// TODO: implement dispose
print("销毁");
super.dispose();
}
}
When I tap the status bar,can't scroll to the top!
I tried to debug this package, I found that in line 344 of the smart_refresher.dart file, just comment the controller property and scroll back to the top, like this
But the pull-down refresh action will give an error.
flutter: ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown while notifying listeners for AnimationController:
flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12:
flutter: '_positions.isNotEmpty'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
flutter: #3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
flutter: #4 _SmartRefresherState._buildWrapperByConfig.<anonymous closure> (package:pull_to_refresh/src/smart_refresher.dart:291:42)
flutter: #5 RefreshWrapperState._handleOffsetCallBack (package:pull_to_refresh/src/internals/indicator_wrap.dart:163:14)
flutter: #6 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #7 AnimationController.value= (package:flutter/src/animation/animation_controller.dart:351:5)
flutter: #8 RefreshWrapperState._handleModeChange (package:pull_to_refresh/src/internals/indicator_wrap.dart:171:25)
flutter: #9 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:208:21)
flutter: #10 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:264:5)
flutter: #11 Wrapper.mode= (package:pull_to_refresh/src/internals/indicator_wrap.dart:31:43)
flutter: #12 RefreshWrapperState.onDragEnd (package:pull_to_refresh/src/internals/indicator_wrap.dart:157:14)
flutter: #13 _SmartRefresherState._handleScrollEnd (package:pull_to_refresh/src/smart_refresher.dart:120:40)
flutter: #14 _SmartRefresherState._dispatchScrollEvent (package:pull_to_refresh/src/smart_refresher.dart:133:16)
flutter: #15 NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:125:27)
flutter: #16 Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:45:20)
flutter: #17 _ScrollNotification&LayoutChangedNotification&ViewportNotificationMixin.visitAncestor (package:flutter/src/widgets/scroll_notification.dart:31:18)
flutter: #18 Element.visitAncestorElements (package:flutter/src/widgets/framework.dart:3344:39)
flutter: #19 Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:59:12)
flutter: #20 ScrollActivity.dispatchScrollUpdateNotification (package:flutter/src/widgets/scroll_activity.dart:96:92)
flutter: #21 ScrollPosition.didUpdateScrollPositionBy (package:flutter/src/widgets/scroll_position.dart:654:14)
flutter: #22 ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:219:9)
flutter: #23 ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18)
flutter: #24 BallisticScrollActivity.applyMoveTo (package:flutter/src/widgets/scroll_activity.dart:547:21)
flutter: #25 BallisticScrollActivity._tick (package:flutter/src/widgets/scroll_activity.dart:534:10)
flutter: #26 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #27 AnimationController._tick (package:flutter/src/animation/animation_controller.dart:697:5)
flutter: #28 Ticker._tick (package:flutter/src/scheduler/ticker.dart:228:5)
flutter: #29 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #30 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
flutter: #31 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
flutter: #32 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
flutter: #33 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:834:5)
flutter: #34 _invoke1 (dart:ui/hooks.dart:168:13)
flutter: #35 _beginFrame (dart:ui/hooks.dart:138:3)
flutter: (elided 2 frames from class _AssertionError)
flutter:
flutter: The AnimationController notifying listeners was:
flutter: AnimationController#96484(⏭ 1.000; paused)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: ScrollController not attached to any scroll views.
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
#0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
#1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
#2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
#3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
#4 _Example1State.build.<anonymous closure>.<anonymous closure> (package:example/ui/Example1.dart:76:83)
#5 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#8 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#9 Future._complete (dart:as<…>
Relevant doctor info:
[✓] Flutter (Channel dev, v0.11.6, on Mac OS X 10.13.6 17G65, locale
zh-Hans-CN) [✓] Android toolchain - develop for Android devices
(Android SDK 28.0.3) [✓] iOS toolchain - develop for iOS devices
(Xcode 10.1) [✓] Android Studio (version 3.2)
[✓] VS Code (version> 1.29.1)
[✓] Connected device (1 available)
Please help me solve this bug, thank you.
dart package flutter
add a comment |
I am using this package.
The package is a widget provided to the flutter scroll component drop-down refresh and pull up load.support android and ios
The package url is https://pub.dartlang.org/packages/pull_to_refresh
But this package has a bug !
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Example1 extends StatefulWidget {
@override
_Example1State createState() => new _Example1State();
}
class _Example1State extends State<Example1> {
// RefreshMode refreshing = RefreshMode.idle;
// LoadMode loading = LoadMode.idle;
RefreshController _refreshController;
List<Widget> data = ;
void _getDatas() {
for (int i = 0; i < 14; i++) {
data.add(new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data $i'),
),
));
}
}
void enterRefresh() {
_refreshController.requestRefresh(true);
}
void _onOffsetCallback(bool isUp, double offset) {
// if you want change some widgets state ,you should rewrite the callback
}
@override
void initState() {
// TODO: implement initState
_getDatas();
_refreshController = new RefreshController();
super.initState();
}
Widget _headerCreate(BuildContext context, int mode) {
return new ClassicIndicator(
mode: mode,
refreshingText: "",
idleIcon: new Container(),
idleText: "Load more...",
);
}
// Widget _footerCreate(BuildContext context,int mode){
// return new ClassicIndicator(mode: mode);
// }
@override
Widget build(BuildContext context) {
return new Container(
child: new SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: _refreshController,
onRefresh: (up) {
if (up)
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
_refreshController.scrollTo(_refreshController.scrollController.offset+100.0);
_refreshController.sendBack(true, RefreshStatus.idle);
setState(() {});
// refresher.sendStatus(RefreshStatus.completed);
});
else {
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
setState(() {});
_refreshController.sendBack(false, RefreshStatus.idle);
});
}
},
onOffsetChange: _onOffsetCallback,
child: new ListView.builder(
reverse: true,
itemExtent: 100.0,
itemCount: data.length,
itemBuilder: (context, index) => new Item(),
)));
}
}
class Item extends StatefulWidget {
@override
_ItemState createState() => new _ItemState();
}
class _ItemState extends State<Item> {
@override
Widget build(BuildContext context) {
return new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data'),
),
);
}
@override
void dispose() {
// TODO: implement dispose
print("销毁");
super.dispose();
}
}
When I tap the status bar,can't scroll to the top!
I tried to debug this package, I found that in line 344 of the smart_refresher.dart file, just comment the controller property and scroll back to the top, like this
But the pull-down refresh action will give an error.
flutter: ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown while notifying listeners for AnimationController:
flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12:
flutter: '_positions.isNotEmpty'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
flutter: #3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
flutter: #4 _SmartRefresherState._buildWrapperByConfig.<anonymous closure> (package:pull_to_refresh/src/smart_refresher.dart:291:42)
flutter: #5 RefreshWrapperState._handleOffsetCallBack (package:pull_to_refresh/src/internals/indicator_wrap.dart:163:14)
flutter: #6 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #7 AnimationController.value= (package:flutter/src/animation/animation_controller.dart:351:5)
flutter: #8 RefreshWrapperState._handleModeChange (package:pull_to_refresh/src/internals/indicator_wrap.dart:171:25)
flutter: #9 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:208:21)
flutter: #10 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:264:5)
flutter: #11 Wrapper.mode= (package:pull_to_refresh/src/internals/indicator_wrap.dart:31:43)
flutter: #12 RefreshWrapperState.onDragEnd (package:pull_to_refresh/src/internals/indicator_wrap.dart:157:14)
flutter: #13 _SmartRefresherState._handleScrollEnd (package:pull_to_refresh/src/smart_refresher.dart:120:40)
flutter: #14 _SmartRefresherState._dispatchScrollEvent (package:pull_to_refresh/src/smart_refresher.dart:133:16)
flutter: #15 NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:125:27)
flutter: #16 Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:45:20)
flutter: #17 _ScrollNotification&LayoutChangedNotification&ViewportNotificationMixin.visitAncestor (package:flutter/src/widgets/scroll_notification.dart:31:18)
flutter: #18 Element.visitAncestorElements (package:flutter/src/widgets/framework.dart:3344:39)
flutter: #19 Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:59:12)
flutter: #20 ScrollActivity.dispatchScrollUpdateNotification (package:flutter/src/widgets/scroll_activity.dart:96:92)
flutter: #21 ScrollPosition.didUpdateScrollPositionBy (package:flutter/src/widgets/scroll_position.dart:654:14)
flutter: #22 ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:219:9)
flutter: #23 ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18)
flutter: #24 BallisticScrollActivity.applyMoveTo (package:flutter/src/widgets/scroll_activity.dart:547:21)
flutter: #25 BallisticScrollActivity._tick (package:flutter/src/widgets/scroll_activity.dart:534:10)
flutter: #26 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #27 AnimationController._tick (package:flutter/src/animation/animation_controller.dart:697:5)
flutter: #28 Ticker._tick (package:flutter/src/scheduler/ticker.dart:228:5)
flutter: #29 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #30 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
flutter: #31 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
flutter: #32 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
flutter: #33 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:834:5)
flutter: #34 _invoke1 (dart:ui/hooks.dart:168:13)
flutter: #35 _beginFrame (dart:ui/hooks.dart:138:3)
flutter: (elided 2 frames from class _AssertionError)
flutter:
flutter: The AnimationController notifying listeners was:
flutter: AnimationController#96484(⏭ 1.000; paused)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: ScrollController not attached to any scroll views.
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
#0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
#1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
#2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
#3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
#4 _Example1State.build.<anonymous closure>.<anonymous closure> (package:example/ui/Example1.dart:76:83)
#5 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#8 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#9 Future._complete (dart:as<…>
Relevant doctor info:
[✓] Flutter (Channel dev, v0.11.6, on Mac OS X 10.13.6 17G65, locale
zh-Hans-CN) [✓] Android toolchain - develop for Android devices
(Android SDK 28.0.3) [✓] iOS toolchain - develop for iOS devices
(Xcode 10.1) [✓] Android Studio (version 3.2)
[✓] VS Code (version> 1.29.1)
[✓] Connected device (1 available)
Please help me solve this bug, thank you.
dart package flutter
I am using this package.
The package is a widget provided to the flutter scroll component drop-down refresh and pull up load.support android and ios
The package url is https://pub.dartlang.org/packages/pull_to_refresh
But this package has a bug !
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Example1 extends StatefulWidget {
@override
_Example1State createState() => new _Example1State();
}
class _Example1State extends State<Example1> {
// RefreshMode refreshing = RefreshMode.idle;
// LoadMode loading = LoadMode.idle;
RefreshController _refreshController;
List<Widget> data = ;
void _getDatas() {
for (int i = 0; i < 14; i++) {
data.add(new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data $i'),
),
));
}
}
void enterRefresh() {
_refreshController.requestRefresh(true);
}
void _onOffsetCallback(bool isUp, double offset) {
// if you want change some widgets state ,you should rewrite the callback
}
@override
void initState() {
// TODO: implement initState
_getDatas();
_refreshController = new RefreshController();
super.initState();
}
Widget _headerCreate(BuildContext context, int mode) {
return new ClassicIndicator(
mode: mode,
refreshingText: "",
idleIcon: new Container(),
idleText: "Load more...",
);
}
// Widget _footerCreate(BuildContext context,int mode){
// return new ClassicIndicator(mode: mode);
// }
@override
Widget build(BuildContext context) {
return new Container(
child: new SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: _refreshController,
onRefresh: (up) {
if (up)
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
_refreshController.scrollTo(_refreshController.scrollController.offset+100.0);
_refreshController.sendBack(true, RefreshStatus.idle);
setState(() {});
// refresher.sendStatus(RefreshStatus.completed);
});
else {
new Future.delayed(const Duration(milliseconds: 2009))
.then((val) {
data.add(new Card(
margin: new EdgeInsets.only(
left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data '),
),
));
setState(() {});
_refreshController.sendBack(false, RefreshStatus.idle);
});
}
},
onOffsetChange: _onOffsetCallback,
child: new ListView.builder(
reverse: true,
itemExtent: 100.0,
itemCount: data.length,
itemBuilder: (context, index) => new Item(),
)));
}
}
class Item extends StatefulWidget {
@override
_ItemState createState() => new _ItemState();
}
class _ItemState extends State<Item> {
@override
Widget build(BuildContext context) {
return new Card(
margin:
new EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
child: new Center(
child: new Text('Data'),
),
);
}
@override
void dispose() {
// TODO: implement dispose
print("销毁");
super.dispose();
}
}
When I tap the status bar,can't scroll to the top!
I tried to debug this package, I found that in line 344 of the smart_refresher.dart file, just comment the controller property and scroll back to the top, like this
But the pull-down refresh action will give an error.
flutter: ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown while notifying listeners for AnimationController:
flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12:
flutter: '_positions.isNotEmpty'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
flutter: #3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
flutter: #4 _SmartRefresherState._buildWrapperByConfig.<anonymous closure> (package:pull_to_refresh/src/smart_refresher.dart:291:42)
flutter: #5 RefreshWrapperState._handleOffsetCallBack (package:pull_to_refresh/src/internals/indicator_wrap.dart:163:14)
flutter: #6 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #7 AnimationController.value= (package:flutter/src/animation/animation_controller.dart:351:5)
flutter: #8 RefreshWrapperState._handleModeChange (package:pull_to_refresh/src/internals/indicator_wrap.dart:171:25)
flutter: #9 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:208:21)
flutter: #10 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:264:5)
flutter: #11 Wrapper.mode= (package:pull_to_refresh/src/internals/indicator_wrap.dart:31:43)
flutter: #12 RefreshWrapperState.onDragEnd (package:pull_to_refresh/src/internals/indicator_wrap.dart:157:14)
flutter: #13 _SmartRefresherState._handleScrollEnd (package:pull_to_refresh/src/smart_refresher.dart:120:40)
flutter: #14 _SmartRefresherState._dispatchScrollEvent (package:pull_to_refresh/src/smart_refresher.dart:133:16)
flutter: #15 NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:125:27)
flutter: #16 Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:45:20)
flutter: #17 _ScrollNotification&LayoutChangedNotification&ViewportNotificationMixin.visitAncestor (package:flutter/src/widgets/scroll_notification.dart:31:18)
flutter: #18 Element.visitAncestorElements (package:flutter/src/widgets/framework.dart:3344:39)
flutter: #19 Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:59:12)
flutter: #20 ScrollActivity.dispatchScrollUpdateNotification (package:flutter/src/widgets/scroll_activity.dart:96:92)
flutter: #21 ScrollPosition.didUpdateScrollPositionBy (package:flutter/src/widgets/scroll_position.dart:654:14)
flutter: #22 ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:219:9)
flutter: #23 ScrollPositionWithSingleContext.setPixels (package:flutter/src/widgets/scroll_position_with_single_context.dart:84:18)
flutter: #24 BallisticScrollActivity.applyMoveTo (package:flutter/src/widgets/scroll_activity.dart:547:21)
flutter: #25 BallisticScrollActivity._tick (package:flutter/src/widgets/scroll_activity.dart:534:10)
flutter: #26 _AnimationController&Animation&AnimationEagerListenerMixin&AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:124:19)
flutter: #27 AnimationController._tick (package:flutter/src/animation/animation_controller.dart:697:5)
flutter: #28 Ticker._tick (package:flutter/src/scheduler/ticker.dart:228:5)
flutter: #29 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #30 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
flutter: #31 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
flutter: #32 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
flutter: #33 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:834:5)
flutter: #34 _invoke1 (dart:ui/hooks.dart:168:13)
flutter: #35 _beginFrame (dart:ui/hooks.dart:138:3)
flutter: (elided 2 frames from class _AssertionError)
flutter:
flutter: The AnimationController notifying listeners was:
flutter: AnimationController#96484(⏭ 1.000; paused)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: ScrollController not attached to any scroll views.
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
#0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
#1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
#2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
#3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:118:24)
#4 _Example1State.build.<anonymous closure>.<anonymous closure> (package:example/ui/Example1.dart:76:83)
#5 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#8 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#9 Future._complete (dart:as<…>
Relevant doctor info:
[✓] Flutter (Channel dev, v0.11.6, on Mac OS X 10.13.6 17G65, locale
zh-Hans-CN) [✓] Android toolchain - develop for Android devices
(Android SDK 28.0.3) [✓] iOS toolchain - develop for iOS devices
(Xcode 10.1) [✓] Android Studio (version 3.2)
[✓] VS Code (version> 1.29.1)
[✓] Connected device (1 available)
Please help me solve this bug, thank you.
dart package flutter
dart package flutter
asked Nov 21 '18 at 1:36
sunmoonsunmoon
153
153
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404114%2fios-status-bar-tap-fails-scroll-to-the-top%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404114%2fios-status-bar-tap-fails-scroll-to-the-top%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown