【问题标题】:how do i fix this error: RenderBox was not laid out: RenderRepaintBoundary#16fcb relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE我该如何修复此错误:RenderBox 未布局:RenderRepaintBoundary#16fcb relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
【发布时间】:2022-11-29 06:18:24
【问题描述】:

我有一条错误消息:RenderBox 未布局:RenderDecoratedBox#dbfd0 relayoutBoundary=up12 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE。 '包:flutter/src/rendering/box.dart': 断言失败:第 2001 行第 12 行:'hasSize'

我该如何解决这个错误。我看过其他问题,但没有找到解决方案。

      body: SafeArea(
        child: SingleChildScrollView(
        physics: const BouncingScrollPhysics(),



      child: Container(
        decoration: BoxDecoration(
            gradient: LinearGradient(colors: [
              hexStringToColor("FFBEC8"),
              hexStringToColor("fe98a8"),
              hexStringToColor("FC98A7"),
              hexStringToColor("#FF8799")
            ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
          child: Padding(
              padding: EdgeInsets.all(16.0),

              child: Column(
                children: <Widget>[
                  Container(

                    height: 64,
                    margin: EdgeInsets.only(bottom: 20),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        CircleAvatar(
                          radius: 29,
                          backgroundImage: AssetImage(
                              'assets/logo.png'),
                        ),
                        SizedBox(
                          width: 16,
                        ),
                        Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Text(

                        "$name",
                              style: TextStyle(
                                  fontFamily: "Montserrat Medium",
                                  color: Colors.white,
                                  fontSize: 20),
                            ),

                          ],
                        )
                      ],
                    ),

                  ),

                  Expanded(
                    child: GridView.count(
                      shrinkWrap: true,
                      mainAxisSpacing: 10,
                      crossAxisSpacing: 10,
                      primary: false,
                      crossAxisCount: 2,

                      children: <Widget>[
                        Card(
                          color: Colors.grey.shade100,
                          shape:RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(8)
                          ),

                          elevation: 4,
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,

                            children: <Widget>[
                              GestureDetector(
                                onTap:
                          () =>
                              Navigator.of(context).push(PageTransition(
                                  child: PDFScreen(pathPDF: 'assets/arbo',),
                                  type: PageTransitionType.fade)),


                                  child:
                                  SvgPicture.asset(
                                    'assets/moon.svg',
                                    height: 120,
                                  )

                              ),
                              Text(
                                'Arbo-lijst',

                                style: cardTextStyle,
                              )
                            ],
                          ),
                        ),

【问题讨论】:

    标签: android ios flutter text


    【解决方案1】:

    删除 singlechildscrollview 小部件

    您不能在 singlechildscrollview 小部件中使用展开的小部件,singlechildscrollview 是可滚动的小部件。而展开的小部件告诉您的代码占用所有提供的空间。然而,对于可滚动的,它更无限以适合页面上的所有内容。因此基本上是错误。

    只需删除 SingleChildScrollView。

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 1970-01-01
      • 2020-05-08
      • 2020-10-30
      • 1970-01-01
      • 2021-11-18
      • 1970-01-01
      • 2022-01-19
      • 2020-04-12
      相关资源
      最近更新 更多