deviceStatus static method
Implementation
static Future<Map<String, String>> deviceStatus() async {
var connectivity = await Connectivity().checkConnectivity();
var battery = Battery();
var returnVal = <String, String>{
'device_status[network_cell_connected]': (connectivity == ConnectivityResult.mobile).toString(),
'device_status[network_wifi_connected]': (connectivity == ConnectivityResult.wifi).toString(),
};
try {
returnVal.addAll(<String, String>{
'device_status[battery_charging]':
((await battery.onBatteryStateChanged.first) != BatteryState.discharging).toString(),
'device_status[battery_level]': (await battery.batteryLevel).toString(),
});
} catch (err) {
print(err);
}
return returnVal;
}