at value: await statusonoff(device),
I am getting an error saying The argument type 'Future' can't be assigned to the parameter type 'bool'. when i retrive a bool from the firestore
static Future<bool>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: await statusonoff(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(context, device);
}
status = value;
});
},
),