RenderFlex在右侧溢出了27个像素

时间:2020-10-16 14:57:16

标签: flutter dart singlechildscrollview

在出现此错误之前,我遇到了相同的错误,并使用Expanded和SingleChildScrollView小部件解决了该错误。但是这次它不起作用。我的代码在下面。

  Widget build(BuildContext context) {

    return Container(
      child:SizedBox(
        height: height,
        child: SlideButton(
          isDraggable: true,
          backgroundColor: color.withOpacity(0.9),
          backgroundChild: Center(
            child: Container(
              margin: EdgeInsets.fromLTRB(sizedboxwidth, 0, 0, 0),
              child: CupertinoButton(
                onPressed: (){},
                child: Row(
                  children: [
                    CircleAvatar(
                      child: Image.asset("assets/world_2.png"),

                    ),
                    SizedBox(width:10),
                    Text(user.getUserName(),
                      style: TextStyle(
                          color: textcolor,
                          fontSize: 20,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
          slidingBarColor: backgroundcolor.withOpacity(0.4),
          //initialSliderPercentage: initialSliderPercent,
          
          slidingChild: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Expanded(
                child: SingleChildScrollView(
                  child: Row(
                    children: [
                      Opacity(
                          child: Icon(Icons.arrow_forward_ios),
                          opacity: 1
                      ),
                      Opacity(
                        child: Icon(Icons.message),
                          opacity: 1
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
          slideDirection: SlideDirection.RIGHT,

        ),
      ),
    );


  }
}

错误如下。

The following assertion was thrown during layout:
A RenderFlex overflowed by 39 pixels on the right.

The relevant error-causing widget was: 
Row file:///C:/src/flutter_project/xcx/lib/components/cards/specified_user_card.dart:74:26
The overflowing RenderFlex has an orientation of Axis.horizontal.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and 
black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the       
RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. 
If the content is legitimately bigger than the available space, consider clipping it with a ClipRect 
widget before putting it in the flex, or using a scrollable container rather than a Flex, like a 
ListView.

我也尝试过ClipRect小部件,但对我而言不起作用。当分配了slideChildChild属性的小部件移到左侧时,会发生问题。

0 个答案:

没有答案