Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - how to make nested list views?

Tags:

flutter

dart

I want to make a nested list view in the following manner

enter image description here

How can I do this? I only want the nested list view for one of the radio tiles not all of them.

I tried including both ListView builder in another List however there was rendering problem.

My code:

Column(

      children: <Widget>[
        .....

        Expanded(
          child:

          ListView.builder(
            padding: EdgeInsets.all(0.0),
            itemCount: tasks.length,
            itemBuilder: (context, index) {

              return RadioListTile<String>(

               //contentPadding: EdgeInsets.symmetric(horizontal: 16.0),
                title:  Text(tasks[index], style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w400)),
                value: tasks[index],
                groupValue: selectedRadio,
                onChanged: (val){
                    setSelectedRadio(val);
                }
              );
            },
          ),
        ),

      ],
    );

like image 988
Mandel Avatar asked Mar 14 '26 04:03

Mandel


1 Answers

You cannot build a ListView inside a ListView as you will confuse the scroll behaviour. You should use List widget that does not scroll, such as Column.

ListView.builder(
  padding: EdgeInsets.all(0.0),
  itemCount: tasks.length,
  itemBuilder: (context, index) {
    if (// single RadioListTile) {
      return RadioListTile<String>(
        title:  Text(tasks[index], style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w400)),
        value: tasks[index],
        groupValue: selectedRadio,
        onChanged: (val) => setSelectedRadio(val),
      );
    }
    else if (// nested RadioListTile) {
      return Column(
        children: <Widget>[
          // RadioListTile1,
          // RadioListTile2,
          // RadioListTile3,
        ],
      );
    }
  },
),
like image 160
Michael Yuwono Avatar answered Mar 15 '26 22:03

Michael Yuwono



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!