RenderObject具有以下子孙,NEEDS-LAYOUT NEEDS-PAINT

时间:2019-05-06 05:35:38

标签: flutter

您好,我正在制作一个Flutter应用程序,在该应用程序中我需要水平使用ListView。列表视图中的每个内容都会显示一个问题,并且按下next按钮我必须跳到下一个位置。 这是我的构建方法代码

  Widget build(BuildContext context) {
    return Scaffold(
      //debugShowCheckedModeBanner: false,
      //key: scaffoldKey,
      backgroundColor: app_color,

      body: Column(
       // mainAxisAlignment: MainAxisAlignment.spaceEvenly,

        children: <Widget>[

          Container(

            child: IconButton(
              icon: Icon(Icons.arrow_back),
              onPressed: () => {
                Navigator.pop(context)

              },
              color: Colors.white,
              iconSize: 35,
            ),
          ),


          Expanded(
              //margin: const EdgeInsets.fromLTRB(0.0, 30.0  , 0.0 , 0.0 ),
              //height: double.infinity,

              child:
                 ListView.builder(
                    itemCount: question_list.length,
                    scrollDirection: Axis.horizontal,
                    // shrinkWrap: true,
                    itemBuilder:(context, position){
                      return Container(
                        width: double.infinity,
                        height: 400,
                        child: Column(
                          children: <Widget>[
                            Container(
                              margin: EdgeInsets.all(10),
                              padding: EdgeInsets.all(20),
                              child:Text(question_list[position].quiz_question,
                                style: TextStyle(fontSize: 18.0,color: Colors.white),),
                            ),

                            Column(
                              children: <Widget>[
                                Row(
                                  children: <Widget>[
                                    Radio(
                                      value: 1,
                                      groupValue: _radioValue,
                                      onChanged: _handleRadioValueChange,
                                    ),
                                    Container(
                                      margin: EdgeInsets.all(10),

                                      child:Text(question_list[position].option_1,
                                        style: TextStyle(fontSize: 18.0,color: Colors.white),),
                                    ),
                                  ],
                                ),

                                Row(
                                  children: <Widget>[
                                    Radio(
                                      value: 0,
                                      groupValue: _radioValue,
                                      onChanged: _handleRadioValueChange,
                                    ),
                                    Container(
                                      margin: EdgeInsets.all(10),

                                      child:Text(question_list[position].option_2,
                                        style: TextStyle(fontSize: 18.0,color: Colors.white),),
                                    ),
                                  ],
                                ),
                              ],
                            )

                          ],
                        ),
                      );
                    }
                ),
          ),

          //                                                                                                                
        ],
      ),

    );
  }

现在,这给了我

错误
I/flutter ( 5603):   constraints: BoxConstraints(0.0<=w<=Infinity, h=629.0)
I/flutter ( 5603):   size: MISSING
I/flutter ( 5603):   additionalConstraints: BoxConstraints(w=Infinity, h=400.0)
I/flutter ( 5603): This RenderObject had the following descendants (showing up to depth 5):
I/flutter ( 5603):   RenderFlex#4a4fc NEEDS-LAYOUT NEEDS-PAINT

请纠正我我在这里做错了什么?当我评论这条线时  对于ListView的scrollDirection,它可以正常工作,但在水平方向上会出现错误。在此先感谢

0 个答案:

没有答案