3

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);
                }
              );
            },
          ),
        ),

      ],
    );

0

2 Answers 2

4

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,
        ],
      );
    }
  },
),
Sign up to request clarification or add additional context in comments.

Comments

1

You can totally include a list view inside of another list view. But the inside list view has to have shrinkWrap set to true

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.