Open lan2000 opened 2 years ago
@lan2000 Thanks for your feedback. The issue fixed in flutter_chat_list: ^1.0.2, please update it.
下拉,拉取历史消息的时候,列表有回弹的问题。把FlutterListView的keepPosition改为false就正常。
正常情况,下拉触发加载的时候,头部loading会一直显示直到数据加载完成才会隐藏。但是现在快速下拉滑动,触发加载,头部loading停顿下立马就隐藏了,导致列表还回退了。
下面是把FlutterListView的keepPosition改为false的情况
The keepPosition has own functinality. But it has little demerit in implement. KeepPosition have be rewrote. Please update it to last version.
连续向下滑动,不停加载页面。有概率出现错误:
======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for ValueNotifier<bool>:
Build scheduled during frame.
While the widget tree was being built, laid out, and painted, a new frame was scheduled to rebuild the widget tree.
This might be because setState() was called from a layout or paint callback. If a change is needed to the widget tree, it should be applied as the tree is being built. Scheduling a change for the subsequent frame instead results in an interface that lags behind by one frame. If this was done to make your build dependent on a size measured at layout time, consider using a LayoutBuilder, CustomSingleChildLayout, or CustomMultiChildLayout. If, on the other hand, the one frame delay is the desired effect, for example because this is an animation, consider scheduling the frame in a post-frame callback using SchedulerBinding.addPostFrameCallback or using an AnimationController to trigger the animation.
When the exception was thrown, this was the stack:
#0 WidgetsBinding._handleBuildScheduled.<anonymous closure> (package:flutter/src/widgets/binding.dart:747:9)
#1 WidgetsBinding._handleBuildScheduled (package:flutter/src/widgets/binding.dart:770:6)
#2 BuildOwner.scheduleBuildFor (package:flutter/src/widgets/framework.dart:2485:24)
#3 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4443:12)
#4 State.setState (package:flutter/src/widgets/framework.dart:1141:15)
#5 LoadIndicatorState.enterLoading (package:pull_to_refresh/src/internals/indicator_wrap.dart:364:5)
#6 LoadIndicatorState._listenScrollEnd (package:pull_to_refresh/src/internals/indicator_wrap.dart:507:51)
#7 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:308:24)
#8 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:412:5)
#9 ScrollPosition.beginActivity (package:flutter/src/widgets/scroll_position.dart:885:25)
#10 ScrollPositionWithSingleContext.beginActivity (package:flutter/src/widgets/scroll_position_with_single_context.dart:114:11)
#11 ScrollPositionWithSingleContext.goIdle (package:flutter/src/widgets/scroll_position_with_single_context.dart:129:5)
#12 ScrollPositionWithSingleContext.goBallistic (package:flutter/src/widgets/scroll_position_with_single_context.dart:148:7)
#13 ScrollDragController.cancel (package:flutter/src/widgets/scroll_activity.dart:417:14)
#14 ScrollableState._handleDragCancel (package:flutter/src/widgets/scrollable.dart:661:12)
#15 ScrollableState.setCanDrag (package:flutter/src/widgets/scrollable.dart:550:7)
#16 ScrollPositionWithSingleContext.applyNewDimensions (package:flutter/src/widgets/scroll_position_with_single_context.dart:105:13)
#17 ScrollPosition.applyContentDimensions (package:flutter/src/widgets/scroll_position.dart:553:7)
#18 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1493:20)
#19 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1731:7)
#20 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
#21 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:497:19)
#22 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13)
#23 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#24 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#25 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#26 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#30 _invoke (dart:ui/hooks.dart:151:10)
#31 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#32 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
The ValueNotifier<bool> sending notification was: ValueNotifier<bool>#47d1d(false)
====================================================================================================
I/InputTransport(21333): Fun_filterMotionEvent reportMoveEvent!
W/HiTouch_PressGestureDetector(21333): Touch pointer move a lot. The moving distance of X is:5.0, limit is:60The moving distance of Y is:122.0, limit is:60
W/HiTouch_PressGestureDetector(21333): Touch pointer move a lot. The moving distance of X is:11.0, limit is:60The moving distance of Y is:72.0, limit is:60
W/HiTouch_PressGestureDetector(21333): Touch pointer move a lot. The moving distance of X is:32.0, limit is:60The moving distance of Y is:105.0, limit is:60
======== Exception caught by widgets library =======================================================
The following assertion was thrown building RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#e5d83](state: RawGestureDetectorState#f6dc4(gestures: [vertical drag], behavior: opaque)):
A ScrollPositionWithSingleContext was used after being disposed.
Once you have called dispose() on a ScrollPositionWithSingleContext, it can no longer be used.
The relevant error-causing widget was:
SmartRefresher SmartRefresher:file:///D:/flutter_develop/medicalcloud_support_dependencies/flutter_chat_list_test/lib/src/chat_list.dart:459:14
When the exception was thrown, this was the stack:
#0 ChangeNotifier._debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:114:9)
#1 ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:120:6)
#2 ChangeNotifier.removeListener (package:flutter/src/foundation/change_notifier.dart:233:12)
#3 IndicatorStateMixin._updateListener (package:pull_to_refresh/src/internals/indicator_wrap.dart:634:18)
#4 IndicatorStateMixin.didUpdateWidget (package:pull_to_refresh/src/internals/indicator_wrap.dart:671:5)
#5 StatefulElement.update (package:flutter/src/widgets/framework.dart:4943:57)
#6 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#7 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
#8 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
#9 _ViewportElement.update (package:flutter/src/widgets/viewport.dart:228:11)
#10 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#11 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#12 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#13 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#14 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#15 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#16 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#17 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#18 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#19 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#20 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#21 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#22 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#23 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#24 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#25 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#26 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#27 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#28 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#29 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#30 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#31 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#32 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#33 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#34 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#35 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#36 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#37 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#38 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#39 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#40 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#41 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#42 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#43 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#44 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#45 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#46 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#47 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#48 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#49 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#50 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#51 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#52 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#53 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#54 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#55 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#56 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#57 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#58 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#59 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#60 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#61 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#62 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#63 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#64 _LayoutBuilderElement._layout.layoutCallback (package:flutter/src/widgets/layout_builder.dart:138:18)
#65 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2600:19)
#66 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:156:12)
#67 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1997:59)
#68 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15)
#69 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1997:14)
#70 RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:230:7)
#71 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:319:5)
#72 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1731:7)
#73 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
#74 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:497:19)
#75 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13)
#76 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#77 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#78 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#79 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#83 _invoke (dart:ui/hooks.dart:151:10)
#84 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#85 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
====================================================================================================
======== Exception caught by foundation library ====================================================
The following _CastError was thrown while dispatching notifications for RefreshNotifier<LoadStatus>:
Null check operator used on a null value
When the exception was thrown, this was the stack:
#0 LoadIndicatorState._handleModeChange (package:pull_to_refresh/src/internals/indicator_wrap.dart:437:30)
#1 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:308:24)
#2 RefreshNotifier.value= (package:pull_to_refresh/src/smart_refresher.dart:1059:5)
#3 RefreshController.loadComplete.<anonymous closure> (package:pull_to_refresh/src/smart_refresher.dart:789:19)
#4 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#5 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1089:9)
#6 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#10 _invoke (dart:ui/hooks.dart:151:10)
#11 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#12 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
The RefreshNotifier<LoadStatus> sending notification was: RefreshNotifier<LoadStatus>#9c1fa(LoadStatus.idle)
====================================================================================================
使用最新的flutter_chat_list 1.0.5
Please update to flutter_chat_list: ^1.0.6. Fixed random scrollposition error when refreshController.requestLoading was invoked. It caused by manually call refreshController.requestLoading(). The error will supress if we pass needMove: false.
flutter_chat_list 1.0.6
偶然报错:
I/flutter (29904): The following assertion was thrown building Container(padding:
I/flutter (29904): EdgeInsets(12.0, 5.0, 12.0, 5.0)):
I/flutter (29904): 'package:flutter/src/rendering/object.dart': Failed assertion:
I/flutter (29904): line 1627 pos 14:
I/flutter (29904): '_debugSubtreeRelayoutRootAlreadyMarkedNeedsLayout()': is not
I/flutter (29904): true.
I/flutter (29904):
I/flutter (29904): Either the assertion indicates an error in the framework itself,
I/flutter (29904): or we should provide substantially more information in this error
I/flutter (29904): message to help you determine and fix the underlying cause.
I/flutter (29904): In either case, please report this assertion by filing a bug on
I/flutter (29904): GitHub:
I/flutter (29904): https://github.com/flutter/flutter/issues/new?template=2_bug.md
I/flutter (29904):
I/flutter (29904): The relevant error-causing widget was:
I/flutter (29904): Container
I/flutter (29904):
I/flutter (29904):
I/flutter (29904): When the exception was thrown, this was the stack:
I/flutter (29904): #2 RenderObject.markNeedsLayout (package:flutter/src/rendering/
找到复现的方法了,替换demo里面的test_chat_list.dart test_chat_list.zip
操作如下: 点击列表条目,弹出一个弹窗,关闭弹窗,手机横屏,点击底部的编辑框。 操作视频:
日志:
======== Exception caught by widgets library =======================================================
The following assertion was thrown building Container(margin: EdgeInsets(12.0, 5.0, 12.0, 5.0)):
'package:flutter/src/rendering/object.dart': Failed assertion: line 1627 pos 14: '_debugSubtreeRelayoutRootAlreadyMarkedNeedsLayout()': is not true.
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
The relevant error-causing widget was:
Container Container:file:///D:/flutter/flutter_chat_list_test/example/lib/test_chat_list.dart:341:14
When the exception was thrown, this was the stack:
#2 RenderObject.markNeedsLayout (package:flutter/src/rendering/object.dart:1627:14)
#3 RenderBox.markNeedsLayout (package:flutter/src/rendering/box.dart:2373:11)
#4 RenderParagraph.text= (package:flutter/src/rendering/paragraph.dart:146:9)
#5 RichText.updateRenderObject (package:flutter/src/widgets/basic.dart:5588:9)
#6 RenderObjectElement._performRebuild (package:flutter/src/widgets/framework.dart:5668:12)
#7 RenderObjectElement.update (package:flutter/src/widgets/framework.dart:5647:5)
#8 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6442:11)
#9 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#10 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#13 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#14 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#15 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#16 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#17 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#18 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#19 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#20 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#21 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#22 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#23 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#24 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#26 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#27 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#28 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#29 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#30 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#31 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2659:19)
#32 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
#33 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#34 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#35 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#36 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#40 _invoke (dart:ui/hooks.dart:151:10)
#41 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#42 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 5 frames from class _AssertionError and dart:async)
====================================================================================================
After I observe your video, There is no room space show chat list when the phone turn to horizontal. Would you please make sure it has more room space show chat list?
Thanks,
我现在屏蔽掉appbar,就有一部分空间显示chat list,任然会出现上面的问题
// appBar: AppBar( // title: const Text("Complex Chat"), // actions: [ // TextButton( // onPressed: _mockToReceiveMessage, // child: const Text( // "Mock To Receive", // style: TextStyle(color: Colors.white), // )) // ], // ),
不是空间不够的原因。相同情况下,我只要把列表item里面的RichText替换成Text就不会出现这个问题
///新增
class TestItem extends StatelessWidget {
final int index;
TestItem(this.index,{Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () async{
await showCupertinoDialog<bool>(
context: context,
builder: (context) {
return WillPopScope(
onWillPop: () async {
return true;
},
child: CupertinoAlertDialog(
title: Text('title'),
actions: [
CupertinoDialogAction(
onPressed: () {},
child: Text(
'btn1',
),
),
CupertinoDialogAction(
onPressed: () {},
child: Text(
'btn2',
),
),
],
),
);
});
},
// child: Container(
// margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
// child: RichText(
// text: TextSpan(children: [
// WidgetSpan(
// child: Text('345345345345', style: TextStyle(fontSize: 14)),
// ),
// // WidgetSpan(
// // child:Text('uuuuuuuuuuuuuuuu',
// // style: TextStyle(fontSize: 14)),
// // ),
// ]),
// ),
// ),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
child: Text('345345345345', style: TextStyle(fontSize: 14)),
),
);
}
}
而且关键操作是显示一个弹窗,如果只单单横屏也不会出现这个问题
await showCupertinoDialog<bool>(
context: context,
builder: (context) {
return WillPopScope(
onWillPop: () async {
return true;
},
child: CupertinoAlertDialog(
title: Text('title'),
actions: [
CupertinoDialogAction(
onPressed: () {},
child: Text(
'btn1',
),
),
CupertinoDialogAction(
onPressed: () {},
child: Text(
'btn2',
),
),
],
),
);
});
把showCupertinoDialog换成下面的showDialog也不会出现问题
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(
'我是标题',
textAlign: TextAlign.center,
),
content: Container(
child: Text('内容'),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('取消'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('确定'),
),
],
));
所以出现问题的关键:1、RichText 2、showCupertinoDialog
测试手机是华为nova6
Error when using TabBarView+AutomaticKeepAliveClientMixin.
flutter_chat_list 1.0.1