创建这样的复选框:
for (var a in user.poll.questions[i].options) {
children.add(
new Row(
children: [
new Checkbox(
value: checkBoxValue,
onChanged: (bool newValue) {
setState(() {
checkBoxValue = newValue;
});
}
),
new Text(a.text),
],
),
);
}
这将创建它:
这是我所需要的..但是问题是当一个被选中的所有内容将被更新并被检查并反转时...
我要检查一个..,只有这一项将被检查,我得到它的值..
该怎么做?是否有复选框ID或什么?
答案 0 :(得分:1)
您可以保存选定的问题-类似于:
it('renders a filter tab with expected props after clicking', () => {
const comp = shallowRender({});
comp.find(FilterTab).simulate('click');
expect(comp).toMatchSnapshot();
});
it('calls callback passed after clicking on filter tab', () => {
const filterByNeedsReviewFn = jest.fn()
const comp = shallowRender({ filterByNeedsReviewFn });
comp.find(FilterTab).simulate('click');
// let's ensure callback has been called without any unexpected arguments
expect(filterByNeedsReviewFn ).toHaveBeenCalledWith();
});
UPD 进行多次检查:
1-设置列表而不是一个值
Question selectedQuestion = null;
.....
for (var a in user.poll.questions[i].options) {
children.add(
new Row(
children: [
new Checkbox(
value: selectedQuestion == a,
onChanged: (bool newValue) {
setState(() {
selectedQuestion = a;
});
}
),
new Text(a.text),
],
),
);
}
2-更改CheckBox行为
final List<Question> questionList = [];