首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BoxConstraints强迫无限宽颤振

BoxConstraints强迫无限宽颤振
EN

Stack Overflow用户
提问于 2022-06-10 08:15:28
回答 1查看 82关注 0票数 0

这就是我所犯的错误

代码语言:javascript
复制
> Another exception was thrown: BoxConstraints forces an infinite width.
> 
> Another exception was thrown: RenderBox was not laid out:
> _RenderListTile#bfb7d relayoutBoundary=up18 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderPadding#9ad87 relayoutBoundary=up17 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderPadding#24132 relayoutBoundary=up16 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#09519 relayoutBoundary=up15 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderPointerListener#6e77f relayoutBoundary=up14 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#39ab6 relayoutBoundary=up13 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderMouseRegion#77c75 relayoutBoundary=up12 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#39f2d relayoutBoundary=up11 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#e877e relayoutBoundary=up10 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> _RenderInkFeatures#8f433 relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderCustomPaint#ded6d relayoutBoundary=up8 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderPhysicalShape#9e5aa relayoutBoundary=up7 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderPadding#ef085 relayoutBoundary=up6 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#e3df0 relayoutBoundary=up5 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown: RenderBox was not laid out:
> RenderRepaintBoundary#88219 relayoutBoundary=up4 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
> 
> Another exception was thrown:
> 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed
> assertion: line 544 pos 12: 'child.hasSize': is not true.

这是密码:

代码语言:javascript
复制
return Container(
height: size.height,
width: size.width,
child: Stack(alignment: Alignment.center, children: <Widget>[
  Container(
    width: 300,
    height: 100,
    margin: EdgeInsets.only(bottom: 490, right: 10),
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(19),
          topRight: Radius.circular(19),
          bottomLeft: Radius.circular(19),
          bottomRight: Radius.circular(19)),
      boxShadow: [
        BoxShadow(
          color: Color.fromARGB(255, 185, 203, 203).withOpacity(0.5),
          spreadRadius: 5,
          blurRadius: 7,
          offset: Offset(0, 3), // changes position of shadow
        ),
      ],
    ),
  ),
  Container(
    margin: EdgeInsets.only(bottom: 550, right: 140),
    child: Text(
      "Filter by Patient",
      style: TextStyle(color: Colors.teal, fontSize: 17),
    ),
  ),
  Container(
    //list image profile
    width: 200,
    height: 80,
    margin: EdgeInsets.only(bottom: 650, right: 140),
    child: StreamBuilder<QuerySnapshot>(
      stream: db.collection("patient").snapshots(),
      builder: (BuildContext context, AsyncSnapshot snapshot) {
        List value = snapshot.data!.docs;
        if (snapshot.data == null) {
          return Container(child: Center(child: Text("Loading...")));
        } else {
          return ListView.builder(
              scrollDirection: Axis.horizontal,
              itemBuilder: (context, index) {
                print(snapshot.data!.docs);
                return Card(
                    child: ListTile(
                  leading: CircleAvatar(
                    backgroundImage:
                        NetworkImage(value[index]['imageURL']),
                  ),
                ));
              });
        }
      },
    ),
  )
]));
EN

回答 1

Stack Overflow用户

发布于 2022-06-10 08:52:35

在水平列表中使用ListTile引发问题,在listView父级上使用width:200,它可以设置在ListTile宽度上。您可以通过提供宽度将CardListTile包装为一个大小的小部件,它将解决这个问题。

代码语言:javascript
复制
itemBuilder: (context, index) {
  return SizedBox(
    width: 200,
    child: Card(
      child: ListTile(

我将鼓励您检查LayoutBuilder使用的大小和ui/布局

请查看这段视频以了解有关无限高度/宽度的更多信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72571098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档