我对Flutter 翼是个新手,我得到了一个我不能理解的例外.有谁能帮我一下吗?
我得到的例外是
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.
The ParentDataWidget Positioned(right: 0.0, bottom: 0.0) wants to apply ParentData of type
StackParentData to a RenderObject, which has been set up to accept ParentData of incompatible type
FlexParentData.
Usually, this means that the Positioned widget has the wrong ancestor RenderObjectWidget. Typically,
Positioned widgets are placed directly inside Stack widgets.
The offending Positioned is currently placed inside a Row widget.
The ownership chain for the RenderObject that received the incompatible parent data was:
Padding ← Container ← Positioned ← Row ← Stack ← RepaintBoundary ← IndexedSemantics ←
NotificationListener<KeepAliveNotification> ← KeepAlive ← AutomaticKeepAlive ← ⋯
我的代码片段如下
body: Container(
padding: const EdgeInsets.only(top: 25, left: 16, right: 16),
child: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: ListView(
children: [
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 80,
height: 80,
margin: const EdgeInsets.only(left: 25),
decoration: BoxDecoration(
boxShadow: const [
BoxShadow(
spreadRadius: 2.0,
blurRadius: 10.0,
color: Colors.black,
offset: Offset(0, 10))
],
shape: BoxShape.circle,
image: ...
),
),
Positioned(
...
),
Container(
margin: const EdgeInsets.only(left: 40.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Naruto",
style: TextStyle(
color:
Theme.of(context).primaryColorLight,
fontSize: 20.0,
),
),
const SizedBox(
height: 5.0,
),
Text(
"Loreum ipusm",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 15.0,
),
),
],
),
),
],
),
],
),
Container(
...
),
],
),
),
),
我知道这与嵌套错误的小部件有关.我不知道如何改变它,不知道哪些小部件嵌套错误,Ffltter为什么会对此抱怨.
如果需要更多的代码,请让我知道.
谢谢你的任何帮助.