【发布时间】:2020-11-16 18:09:52
【问题描述】:
我想要开关的当前状态。我试过了,但我遇到了一个错误类型“未来”不是“布尔”类型的子类型。提前致谢
statusonoff( Device device) async {
DocumentSnapshot variable = await Firestore.instance
.collection('device-configs')
.document(device.id)
.get();
return variable.data['value']['on'];
CustomSwitch(
activeColor: Colors.green,
value: statusonoff(context, device),
onChanged: (value) async {
DocumentSnapshot variable = await Firestore.instance
.collection('device-configs')
.document(device.id)
.get();
print(variable.data['value']['on']);
setState(() {
if (variable.data['value']['on'] == false) {
value = true;
_configMode = "on";
_updateDeviceConfig(context, device);
} else if (variable.data['value']['on'] == true) {
value = false;
_configMode = "off";
_updateDeviceConfig( device);
}
status = value;
});
},
),
【问题讨论】:
标签: flutter dart google-cloud-firestore