【发布时间】:2021-06-10 04:18:03
【问题描述】:
我开发了一个应用程序来提醒老年人他们的服药时间。在这里,他们必须选择药物的剂量,例如一天一次和一天两次。 我创建了一个函数,它接受这个剂量并返回等于这些时间的字段。 例如,如果用户选择“一天三次”,则会出现 3 个字段来选择时间。
当我运行我的应用程序时,出现以下错误:
Column's children must not contain any null values, but a null value was found at index 13
我发现错误是由这个函数引起的:
Widget time(String value) {
Widget w;
if (value == "مرة واحدة في اليوم"){
w = SizedBox(
height: 1,
);}
else if (value == 'مرتان في اليوم') {
w = AddContainer(
text: DateFormat('hh:mm').format(updatedTime2), // ("وقت الدواء"),
onPressed: () {
showModalBottomSheet(
context: context, builder: buildShowModalBottomSheetMedTime2);
});
} else if (value == "ثلاث مرات في اليوم") {
w = Column(
children: [
AddContainer(
text: DateFormat('hh:mm').format(updatedTime2), // ("وقت الدواء"),
onPressed: () {
showModalBottomSheet(
context: context,
builder: buildShowModalBottomSheetMedTime2);
}),
SizedBox(height: 20),
AddContainer(
text: DateFormat('hh:mm').format(updatedTime3), // ("وقت الدواء"),
onPressed: () {
showModalBottomSheet(
context: context,
builder: buildShowModalBottomSheetMedTime3);
}),
SizedBox(height: 20),
],
);
} else if (value == "اربعة مرات في اليوم") {
w = Column(
children: [
AddContainer(
text: DateFormat('hh:mm').format(updatedTime2), // ("وقت الدواء"),
onPressed: () {
showModalBottomSheet(
context: context,
builder: buildShowModalBottomSheetMedTime2);
}),
SizedBox(height: 20),
AddContainer(
text: DateFormat('hh:mm').format(updatedTime3), // ("وقت الدواء"),
onPressed: () {
showModalBottomSheet(
context: context,
builder: buildShowModalBottomSheetMedTime3);
}),
SizedBox(height: 20),
AddContainer(
text: DateFormat('hh:mm').format(updatedTime4), // ("وقت الدواء"),
onPressed: () {
showModalBottomSheet(
context: context,
builder: buildShowModalBottomSheetMedTime4);
}),
SizedBox(height: 20),
],
);
}
return w;
}
我该如何解决这个问题?
【问题讨论】: