我试图使一个黑客新闻阅读器。我收到一个错误,但是我不太确定发生了什么。 当我尝试执行以下步骤时,第一项消失了,并显示了一些错误日志,告诉我'_debugSubtreeRelayoutRootAlreadyMarkedNeedsLayout()':不正确。
向上滚动列表。
向下滚动列表到顶部。
看起来像这样
如果有帮助,我也会上传演示。 https://github.com/keeweeChang/flutter_news/tree/list_error
这是显示错误情况的git。 https://media.giphy.com/media/XKGJrdAvgLcy9zyJwM/giphy.gif
错误日志:I / flutter(30902):W小组件库异常提示══╡ ═══════════════════════════════
I / flutter(30902):抛出了以下断言 FutureBuilder(状态:
I / flutter(30902):_FutureBuilderState#fd3d0):
I / flutter(30902):'package:flutter / src / rendering / object.dart':失败 断言:1409行pos 14:
I /颤振(30902): '_debugSubtreeRelayoutRootAlreadyMarkedNeedsLayout()':不正确。
I / flutter(30902):
I /合子(30902):执行部分代码缓存收集,代码= 59KB, 数据= 43KB
I / flutter(30902):任一断言都指示 框架本身,否则我们应该提供实质性的信息
I / flutter(30902):此错误消息中的更多信息可帮助您 确定并解决根本原因。
I / flutter(30902):无论哪种情况,请通过以下方式报告此断言: 在GitHub上提交错误:
I /颤振(30902): https://github.com/flutter/flutter/issues/new?template=BUG.md
I / flutter(30902):
I / flutter(30902):引发异常时,这是堆栈:
I / flutter(30902):#2 RenderObject.markNeedsLayout (package:flutter / src / rendering / object.dart:1409:14)
I / flutter(30902):#3 RenderBox.markNeedsLayout (package:flutter / src / rendering / box.dart:1842:11)
I / flutter(30902):#4 RenderObject.dropChild (package:flutter / src / rendering / object.dart:1158:5)
我/扑(30902):#5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin.child =(package:flutter / src / rendering / object.dart:2744:7)
我/扑(30902):#6 SingleChildRenderObjectElement.removeChildRenderObject (package:flutter / src / widgets / framework.dart:4909:18)
I / flutter(30902):#7 RenderObjectElement.detachRenderObject (package:flutter / src / widgets / framework.dart:4749:36)
I / flutter(30902):#8 Element.detachRenderObject。 (package:flutter / src / widgets / framework.dart:2866:13)
I / flutter(30902):#9 ComponentElement.visitChildren (package:flutter / src / widgets / framework.dart:3775:14)
I / flutter(30902):#10 Element.detachRenderObject (package:flutter / src / widgets / framework.dart:2865:5)
I / flutter(30902):#11 Element.deactivateChild (package:flutter / src / widgets / framework.dart:2995:11)
I / flutter(30902):#12 Element.updateChild (package:flutter / src / widgets / framework.dart:2760:7)
I / flutter(30902):#13 ComponentElement.performRebuild (package:flutter / src / widgets / framework.dart:3752:16)
I / flutter(30902):#14 Element.rebuild (package:flutter / src / widgets / framework.dart:3564:5)
I / flutter(30902):#15 BuildOwner.buildScope (package:flutter / src / widgets / framework.dart:2277:33)
I /合子(30902):收集代码缓存后,代码= 59KB,数据= 43KB
I /合子(30902):将代码缓存容量增加到256KB
我/扑(30902):#16 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter / src / widgets / binding.dart:700:20)
我/扑(30902):#17 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter / src / rendering / binding.dart:275:5)
我/扑(30902):#18 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter / src / scheduler / binding.dart:990:15)
我/扑(30902):#19 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter / src / scheduler / binding.dart:930:9)
我/扑(30902):#20 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (包:flutter / src / scheduler / binding.dart:842:5)
I / flutter(30902):#24 _invoke(dart:ui / hooks.dart:209:10)
I / flutter(30902):#25 _drawFrame(dart:ui / hooks.dart:168:3)
I / flutter(30902):(从_AssertionError类和 包dart:async)I / flutter(30902):═══════════════════════════════════
I / flutter(30902):引发了另一个异常: 'package:flutter / src / rendering / object.dart':断言失败:行 1153 pos 12:'child.parentData!= null':不正确。
I / flutter(30902):引发了另一个异常:NoSuchMethodError: getter'debugDoingLayout'在null上调用。
I / flutter(30902):引发了另一个异常:RenderBox不是 布置:_RenderListTile#46ebb relayoutBoundary = up5 NEEDS-PAINT 已取消
I / flutter(30902):引发了另一个异常:RenderBox不是 布置:RenderPadding#0a187 relayoutBoundary = up4 NEEDS-PAINT 已取消
I / flutter(30902):引发了另一个异常:RenderBox不是 布置:RenderSemanticsAnnotations#d9f7e relayoutBoundary = up3 需求油漆已拆除
I / flutter(30902):引发了另一个异常:RenderBox不是 布置:RenderPointerListener#e0701 relayoutBoundary = up2 NEEDS-PAINT 已取消
I / flutter(30902):引发了另一个异常:RenderBox不是 布置:RenderSemanticsGestureHandler#57551 relayoutBoundary = up1 需求油漆已拆除
I / flutter(30902):引发了另一个异常:RenderBox不是 布置:RenderFlex#915e5需除漆
I / flutter(30902):引发了另一个异常:NoSuchMethodError: 方法'<='在null上调用。
Flutter医生•Flutter版本1.3.8,位于/ Users / louis / flutter / flutterSDK
•框架修订版e5b1ed7a7f(13天前),2019-03-06 14:23:37 -0800
•发动机修订版f4951df193
•Dart版本2.2.1(内部版本2.2.1-dev.0.0 571ea80e11)
更新
根据我的测试,当我使用固定高度的容器包装商品时,该错误已解决。但我想问一下ListView项目是否不支持动态高度窗口小部件或应该设置的任何选项。还是在调试模式下有问题? 这是已解决问题的小部件结构: Widget Structure
可以这样解决问题:
@override
Widget build(BuildContext context) {
final bloc = StoriesProvider.of(context);
return StreamBuilder(
stream: bloc.items,
builder: (context, AsyncSnapshot<Map<int, Future<ItemModel>>> snapshot) {
return Container(
height: 80,
child: buildItem(snapshot),
);
},
);
}
Widget buildItem(AsyncSnapshot<Map<int, Future<ItemModel>>> snapshot) {
if (!snapshot.hasData) {
...(Create loading widget)
}
else {
...(Create ListTile widget by FutureBuilder)
}
}