我正在尝试获取Cards的列表,并尝试使用 Expanded 小部件,但得到 overflow 错误
我的代码:
new Expanded(
child: StreamBuilder(
stream: Firestore.instance.collection('baby').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
padding: const EdgeInsets.only(top: 10.0),
itemExtent: 25.0,
itemBuilder: (context, index) {
DocumentSnapshot ds = snapshot.data.documents[index];
return //Text(" ${ds['name']} ${ds['vote']}");
Card(
child: Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const ListTile(
leading: const Icon(Icons.album),
title: const Text('The Enchanted Nightingale'),
subtitle: const Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
),
new ButtonTheme.bar( // make buttons use the appropriate styles for cards
child: ButtonBar(
children: [
FlatButton(
child: const Text('BUY TICKETS'),
onPressed: () { /* ... */ },
),
FlatButton(
child: const Text('LISTEN'),
onPressed: () { /* ... */ },
),
],
),
),
],
),
),
);
});
})),
我得到的错误是: Incorrect use of ParentDataWidget.
完整错误:
进行热重装... I / flutter(9119):══╡由WIDGETS LIBRARY引起的异常╞══════════════════════════════════════════════════════════════════════════════════════════════ ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ englishLike I /扑(9119):body1).merge(blackMountainView body1),继承:假的,颜色:颜色(0xdd000000),家族:的Roboto,I /扑(9119):尺寸:14.0,重量:400,基线:字母,decoration:TextDecoration.none,softWrap:wrapped I / flutter(9119):at box width,overflow:clip):I / flutter(9119):不正确使用ParentDataWidget . I / flutter(9119):扩展的小部件必须直接放在Flex小部件中 . I /扑(9119):扩展(没有深度,弯曲:1,肮脏)具有一个Flex祖先,但它们之间有其它窗口小部件:I /扑(9119): - _InkFeatures- [GlobalKey#93e52墨迹再现器I / flutter(9119): - CustomPaint I / flutter(9119): - PhysicalShape(clipper:ShapeBorderClipper,海拔:1.0,颜色:颜色(0xffffffff),shadowColor:I / flutter(9119):颜色(0xff000000))I / flutter( 9119): - 填充(填充:EdgeInsets.all(4.0))I / flutter(9119): - 语义(容器:true,属性:SemanticsProperties,label:null,value:null,hint:null)I / flutter(9119) ): - RepaintBoundary - [<0>] I / flutter(9119): - KeepAlive(keepAlive:false)I / flutter(9119): - SliverFixedExtentList(委托:SliverChildBuilderDelegate#b334e(估计子计数:3))I / flutter (9119): - SliverPadding(填充:EdgeInsets(0.0,10.0,0.0,0.0))I /扑(9119): - 视口(axisDirection:下来,锚定:0.0,偏移:ScrollPositionWithSingleContext#bebad(偏移:I /扑( 9119):0.0,范围:0.0..0.0,视口: 380.0,ScrollableState,AlwaysScrollableScrollPhysics - > I / flutter(9119):ClampingScrollPhysics,IdleScrollActivity#7b3a8,ScrollDirection.idle))I / flutter(9119): - IgnorePointer- [GlobalKey#4c7f9](忽略:false,ignoringSemantics:false)I / flutter(9119): - 语义(容器:false,属性:SemanticsProperties,label:null,value:null,hint:null)I / flutter(9119): - 监听器(监听器:[向下],行为:不透明)I / flutter(9119): - _GestureSemantics I / flutter(9119): - _ExcludableScrollSemantics- [GlobalKey#22165] I / flutter(9119): - RepaintBoundary I / flutter(9119): - CustomPaint I / flutter(9119): - RepaintBoundary I / flutter(9119): - 扩展(flex:1)(这是与有问题的扩展不同)I / flutter(9119):这些小部件不能介于Expanded和Flex之间 . I / flutter(9119):违规扩展的父级的所有权链是:I / flutter(9119):DefaultTextStyle←AnimatedDefaultTextStyle←_InkFeatures- [GlobalKey#93e52墨水渲染器]←I / flutter(9119):NotificationListener←CustomPaint ←←_ShapeBorderPaint PhysicalShape I /扑(9119):←←_MaterialInterior材料←填充←⋯I /扑(9119):════════════════════════ ══════════════════════════════════════════════════ ═══════════════════════════════════════════════════════════════════════════════════════════════════════I I / chatty(9119):uid = 10096(com.example.flutterapp)Thread-3相同的3行I / flutter(9119):抛出另一个异常:不正确使用ParentDataWidget .
UPDATE
这是我得到的输出屏幕:
如果我删除 Expanded ,输出变为如下: