我已经选择了一个RadioButtonGroup并为其设置了一些值。但是我希望用户选择单选按钮时我想要那个位置。
RadioButtonGroup(
labels: <String>[
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optiona,
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optionb,
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optionc,
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optiond,
],
onSelected: (String selected)=> setState((){
print("selected answer="+selected); question_json[index].qstn_id=GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].id;
question_json[index].qstn_answer=selected;
question_status[index].isAnswer=true;
if(!question_status[index].isReviewed){
question_status[index].isReviewed=false;
}
question_status[index].isVisited=true;
print("value of answer"+question_status.length.toString());
}),
picked:question_json[index].qstn_answer,
),
RadioButtonGroup(
labels: <String>[
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optiona,
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optionb,
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optionc,
GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].optiond,
],
onSelected: (String selected)=> setState((){
/*radio_select = true;
nothing_select=false;
both_markreview_radioselect=false;
if(mark_review){
both_markreview_radioselect=true;
}else{
mark_review=false;
both_markreview_radioselect=false;
}*/
print("selected answer="+selected);
question_json[index].qstn_id=GetAssessorLoginModel.response.eventData.students[0].theoryQuestions[mainIndex].id;
question_json[index].qstn_answer=selected;
question_status[index].isAnswer=true;
if(!question_status[index].isReviewed){
question_status[index].isReviewed=false;
}
question_status[index].isVisited=true;
print("value of answer"+question_status.length.toString());
}),
picked:question_json[index].qstn_answer,
),
在Onselected内部的代码中,我正在获取该单选按钮的值,但我想要该位置。