Hello there is am making a flutter application in which i need to use the ListView in horizontal way.Each content in list view will show a question and by pressing next button i have to skip to next position. Here is my build method code

  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),),
                                    ),
                                  ],
                                ),
                              ],
                            )

                          ],
                        ),
                      );
                    }
                ),
          ),

          //                                                                                                                
        ],
      ),

    );
  }

Now this gives me error that

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

Please correct me what i am doing wrong here ? When i comment the line for scrollDirection of ListView it works fine but in horizontal it gives error.Thanks in advance

0 Answers