-2

I am making one quiz app. I have 10 questions list and each have four option. User select answer one by one. Then all answers save and give result in last screen.

    //This is a code of radiobuttongroup

        child: RadioButtonGroup(
                            padding: EdgeInsets.all(20.0),
                            labels: <String>[
                              que_list[index]['option_list'][0],
                              que_list[index]['option_list'][1],
                              que_list[index]['option_list'][2],
                              que_list[index]['option_list'][3]
                            ],
                            labelStyle: TextStyle(
                                fontSize: 15,
                                fontWeight: FontWeight.bold,
                                color: Colors.white),
                            onChange: (String label, int index) {},


                            onSelected: (String selected) async {
                              setState(() {
                                _picked = selected;
                              });
                              //print(selected);
                              print(">>>>>>>>>" + _picked);
                            },
                            picked: _picked,
                            activeColor: Colors.white,


                            },
                          ),

I am getting data from API.


1 Answers1

0

Make another list of answers entered like this -

List<String> selectedAns = [];

After selecting, keep adding the answers to this list-

selectedAns.add(selected);
Keerti Purswani
  • 4,878
  • 3
  • 16
  • 29