I have no idea what is going wrong here. I have two checkbox, one wrap with futureBuilder. But the checkbox wrap with FutureBuilder always can't displayed. If I change to return Text(snapshot.data);
, I can see it display as 1
or 0
.
But if I change to this, it not displayed anything.
return Checkbox(
onChanged: null,
value: snapshot.data == "0"
? false
: true,
);
Full code
...item['questions']
.asMap()
.entries
.map((items) {
return TableRow(children: [
Padding(
padding: EdgeInsets.all(10),
child: Text(items.value['name'])),
FutureBuilder(
future: _workOrderBloc.selectAnswer(
items.value['id']),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Checkbox( // it display empty!!
tristate: true,
onChanged: null,
value: snapshot.data == "0"
? false
: true,
);
} else {
return Text("No data");
}
}),
Checkbox(
tristate: true,
value: answers[items.value['id']] ??
false,
onChanged: (answer) {
setState(() {
answers[items.value['id']] =
answer;
});
},
// onChanged: _onRememberMeChanged,
),
]);
}).toList()
Aucun commentaire:
Enregistrer un commentaire