Incorrect use of ParentDataWidget. 这个错误怎么处理?
来源:7-5 播放器源码分析与自定义播放器UI

qq_稻草人_5
2023-01-07
错误:
下面的错误是点击 视频 播放按钮时触发
======== Exception caught by widgets library =======================================================
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.
The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type StackParentData.
Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a Stack widget.
The ownership chain for the RenderObject that received the incompatible parent data was:
Center ← Expanded ← Stack ← AbsorbPointer ← Listener ← _GestureSemantics ← RawGestureDetector ← GestureDetector ← MouseRegion ← MaterialControls ← ⋯
When the exception was thrown, this was the stack:
#0 RenderObjectElement._updateParentData.<anonymous closure> (package:flutter/src/widgets/framework.dart:6046:11)
#1 RenderObjectElement._updateParentData (package:flutter/src/widgets/framework.dart:6063:6)
#2 ParentDataElement._applyParentData.applyParentDataToChild (package:flutter/src/widgets/framework.dart:5258:15)
#3 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4947:14)
#4 ParentDataElement._applyParentData (package:flutter/src/widgets/framework.dart:5264:5)
#5 ParentDataElement.notifyClients (package:flutter/src/widgets/framework.dart:5308:5)
#6 ProxyElement.updated (package:flutter/src/widgets/framework.dart:5238:5)
#7 ProxyElement.update (package:flutter/src/widgets/framework.dart:5227:5)
#8 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#9 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5908:32)
#10 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6464:17)
#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#12 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6311:14)
#13 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#14 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6311:14)
#15 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#16 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6311:14)
#17 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4920:16)
#19 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5060:11)
#20 Element.rebuild (package:flutter/src/widgets/framework.dart:4617:5)
#21 StatefulElement.update (package:flutter/src/widgets/framework.dart:5083:5)
#22 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4920:16)
#24 Element.rebuild (package:flutter/src/widgets/framework.dart:4617:5)
#25 StatelessElement.update (package:flutter/src/widgets/framework.dart:4971:5)
#26 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#27 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6311:14)
#28 Element.updateChild (package:flutter/src/widgets/framework.dart:3590:15)
#29 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4920:16)
#30 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5060:11)
#31 Element.rebuild (package:flutter/src/widgets/framework.dart:4617:5)
#32 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2687:19)
#33 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
#34 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:374:5)
#35 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1175:15)
#36 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1104:9)
#37 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1015:5)
#38 _invoke (dart:ui/hooks.dart:145:13)
#39 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:320:5)
#40 _drawFrame (dart:ui/hooks.dart:112:31)
==============
看着像是这个地方的错误:
这个问题要怎么解决
注释下面代码后不报错:
写回答
1回答
-
CrazyCodeBoy
2023-01-07
可能是代码适配的问题,你将插件版本改为:
chewie: ^1.2.0
video_player: ^2.1.4
然后复制hi_video_controls.dart到你的工程中
https://git.imooc.com/coding-487/fa-component/src/master/component/hi_video/lib/hi_video_controls.dart00
相似问题