robert-luoqing / chat_list

Support chat list function
MIT License
8 stars 5 forks source link

Error when using TabBarView+AutomaticKeepAliveClientMixin #2

Open lan2000 opened 2 years ago

lan2000 commented 2 years ago

Error when using TabBarView+AutomaticKeepAliveClientMixin. flutter_chat_list 1.0.1

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
'package:flutter/src/foundation/node.dart': Failed assertion: line 112 pos 12: '_owner != null': 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: 
  TabBarView TabBarView:file:///F:/test/flutter_chat_list-1.0.1/example/lib/test_chat_list.dart:61:12
When the exception was thrown, this was the stack: 
#2      AbstractNode.detach (package:flutter/src/foundation/node.dart:112:12)
#3      RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3158:11)
#4      FlutterListViewRender.detach (package:flutter_list_view/src/flutter_list_view_render.dart:837:37)
#5      ContainerRenderObjectMixin.detach (package:flutter/src/rendering/object.dart:3441:13)
#6      RenderViewportBase.detach (package:flutter/src/rendering/viewport.dart:384:11)
#7      RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#8      RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#9      RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#10     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#11     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#12     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#13     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#14     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#15     RenderCustomPaint.detach (package:flutter/src/rendering/custom_paint.dart:528:11)
#16     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#17     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#18     ContainerRenderObjectMixin.detach (package:flutter/src/rendering/object.dart:3441:13)
#19     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#20     ContainerRenderObjectMixin.detach (package:flutter/src/rendering/object.dart:3441:13)
#21     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#22     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#23     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#24     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#25     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#26     ContainerRenderObjectMixin.detach (package:flutter/src/rendering/object.dart:3441:13)
#27     RenderCustomMultiChildLayoutBox.detach (package:flutter/src/rendering/custom_layout.dart:351:11)
#28     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#29     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#30     _RenderCustomClip.detach (package:flutter/src/rendering/proxy_box.dart:1352:11)
#31     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#32     RenderObjectWithChildMixin.detach (package:flutter/src/rendering/object.dart:3160:15)
#33     AbstractNode.dropChild (package:flutter/src/foundation/node.dart:153:13)
#34     RenderObject.dropChild (package:flutter/src/rendering/object.dart:1368:11)
#35     RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:344:9)
#36     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1997:59)
#37     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15)
#38     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1997:14)
#39     RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:338:5)
#40     RenderSliverMultiBoxAdaptor.insertAndLayoutLeadingChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:454:5)
#41     RenderSliverFixedExtentBoxAdaptor.performLayout (package:flutter/src/rendering/sliver_fixed_extent_list.dart:225:32)
#42     RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7)
#43     RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:137:12)
#44     _RenderSliverFractionalPadding.performLayout (package:flutter/src/widgets/sliver_fill.dart:167:11)
#45     RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7)
#46     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:510:13)
#47     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1580:12)
#48     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1489:20)
#49     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1731:7)
#50     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
#51     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:497:19)
#52     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13)
#53     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#54     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#55     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#56     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#60     _invoke (dart:ui/hooks.dart:151:10)
#61     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#62     _drawFrame (dart:ui/hooks.dart:115:31)
(elided 5 frames from class _AssertionError and dart:async)
The following RenderObject was being processed when the exception was fired: RenderSliverFillViewport#b8c74 relayoutBoundary=up2
...  needs compositing
...  parentData: paintOffset=Offset(0.0, 0.0) (can use size)
...  constraints: SliverConstraints(AxisDirection.right, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 320.4, remainingPaintExtent: 360.0, crossAxisExtent: 647.0, crossAxisDirection: AxisDirection.down, viewportMainAxisExtent: 360.0, remainingCacheExtent: 360.0, cacheOrigin: 0.0)
...  geometry: SliverGeometry(scrollExtent: 1440.0, paintExtent: 360.0, maxPaintExtent: 1440.0, hasVisualOverflow: true, cacheExtent: 360.0)
...    scrollExtent: 1440.0
...    paintExtent: 360.0
...    maxPaintExtent: 1440.0
...    hasVisualOverflow: true
...    cacheExtent: 360.0
...  currently live children: 1 to 1
RenderObject: RenderSliverFillViewport#b8c74 relayoutBoundary=up2
  needs compositing
  parentData: paintOffset=Offset(0.0, 0.0) (can use size)
  constraints: SliverConstraints(AxisDirection.right, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 320.4, remainingPaintExtent: 360.0, crossAxisExtent: 647.0, crossAxisDirection: AxisDirection.down, viewportMainAxisExtent: 360.0, remainingCacheExtent: 360.0, cacheOrigin: 0.0)
  geometry: SliverGeometry(scrollExtent: 1440.0, paintExtent: 360.0, maxPaintExtent: 1440.0, hasVisualOverflow: true, cacheExtent: 360.0)
    scrollExtent: 1440.0
    paintExtent: 360.0
    maxPaintExtent: 1440.0
    hasVisualOverflow: true
    cacheExtent: 360.0
  currently live children: 1 to 1
...  child with index 1: RenderIndexedSemantics#fe3d8
...    needs compositing
...    parentData: index=1; keepAlive; layoutOffset=360.0
...    constraints: BoxConstraints(w=360.0, h=647.0)
...    size: Size(360.0, 647.0)
...    index: 1
...    child: RenderRepaintBoundary#4eb25
...      needs compositing
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(w=360.0, h=647.0)
...      layer: OffsetLayer#93b89
...        engine layer: OffsetEngineLayer#1002e
...        handles: 2
...        offset: Offset(0.0, 0.0)
...      size: Size(360.0, 647.0)
...      metrics: 95.7% useful (2 bad vs 44 good)
...      diagnosis: this is an outstandingly useful repaint boundary and should definitely be kept
...      child: RenderPhysicalModel#062c0
...        needs compositing
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(w=360.0, h=647.0)
...        layer: PhysicalModelLayer#31f74
...          engine layer: PhysicalShapeEngineLayer#53c56
...          handles: 2
...          elevation: 0.0
...          color: Color(0xfffafafa)
...        size: Size(360.0, 647.0)
...        elevation: 0.0
...        color: Color(0xfffafafa)
...        shadowColor: Color(0xfffafafa)
...        shape: BoxShape.rectangle
...        borderRadius: BorderRadius.zero
...        child: _RenderInkFeatures#eb179
...          needs compositing
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(w=360.0, h=647.0)
...          size: Size(360.0, 647.0)
...  child with index 2 (kept alive but not laid out): RenderIndexedSemantics#c4dfc
...    needs compositing
...    parentData: index=2; keepAlive; layoutOffset=720.0
...    constraints: BoxConstraints(w=360.0, h=647.0)
...    size: Size(360.0, 647.0)
...    index: 2
...    child: RenderRepaintBoundary#7c549
...      needs compositing
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(w=360.0, h=647.0)
...      layer: OffsetLayer#b07be DETACHED
...        engine layer: OffsetEngineLayer#34e83
...        handles: 1
...        offset: Offset(360.0, 0.0)
...      size: Size(360.0, 647.0)
...      metrics: 96.9% useful (1 bad vs 31 good)
...      diagnosis: this is an outstandingly useful repaint boundary and should definitely be kept
...      child: RenderPhysicalModel#2b504
...        needs compositing
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(w=360.0, h=647.0)
...        layer: PhysicalModelLayer#25a89 DETACHED
...          engine layer: PhysicalShapeEngineLayer#539c2
...          handles: 2
...          elevation: 0.0
...          color: Color(0xfffafafa)
...        size: Size(360.0, 647.0)
...        elevation: 0.0
...        color: Color(0xfffafafa)
...        shadowColor: Color(0xfffafafa)
...        shape: BoxShape.rectangle
...        borderRadius: BorderRadius.zero
...        child: _RenderInkFeatures#31931
...          needs compositing
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(w=360.0, h=647.0)
...          size: Size(360.0, 647.0)
====================================================================================================
robert-luoqing commented 2 years ago

@lan2000 Thanks for your feedback. The issue fixed in flutter_chat_list: ^1.0.2, please update it.

lan2000 commented 2 years ago

下拉,拉取历史消息的时候,列表有回弹的问题。把FlutterListView的keepPosition改为false就正常。

lan2000 commented 2 years ago

正常情况,下拉触发加载的时候,头部loading会一直显示直到数据加载完成才会隐藏。但是现在快速下拉滑动,触发加载,头部loading停顿下立马就隐藏了,导致列表还回退了。

lan2000 commented 2 years ago

https://user-images.githubusercontent.com/29618907/168423977-7a80ff80-d855-46b3-ae7a-206205991e11.mp4

lan2000 commented 2 years ago

下面是把FlutterListView的keepPosition改为false的情况

https://user-images.githubusercontent.com/29618907/168424042-ceea9a76-08a7-4336-bf0f-e8175994afca.mp4

robert-luoqing commented 2 years ago

The keepPosition has own functinality. But it has little demerit in implement. KeepPosition have be rewrote. Please update it to last version.

lan2000 commented 2 years ago

连续向下滑动,不停加载页面。有概率出现错误:

======== 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)
====================================================================================================
lan2000 commented 2 years ago

QQ图片20220515124355

lan2000 commented 2 years ago

使用最新的flutter_chat_list 1.0.5

robert-luoqing commented 2 years ago

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.

lan2000 commented 2 years ago

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/
lan2000 commented 2 years ago

找到复现的方法了,替换demo里面的test_chat_list.dart test_chat_list.zip

操作如下: 点击列表条目,弹出一个弹窗,关闭弹窗,手机横屏,点击底部的编辑框。 操作视频:

https://user-images.githubusercontent.com/29618907/171758241-aaf501f9-a80a-4d3a-a942-ac53243cd6a9.mp4

lan2000 commented 2 years ago

日志:

======== 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)
====================================================================================================
robert-bitguild commented 2 years ago

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,

lan2000 commented 2 years ago

我现在屏蔽掉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), // )) // ], // ),

image

lan2000 commented 2 years ago

不是空间不够的原因。相同情况下,我只要把列表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)),
      ),
    );
  }
}
lan2000 commented 2 years ago

而且关键操作是显示一个弹窗,如果只单单横屏也不会出现这个问题

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',
                      ),
                    ),
                  ],
                ),
              );
            });
lan2000 commented 2 years ago

把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