getStatistics method
Gets statistics on this device of type
('charging', 'discharging').
Implementation
Future<List<UPowerDeviceStatisticsRecord>> getStatistics(String type) async {
var result = await _object.callMethod(
'org.freedesktop.UPower.Device', 'GetStatistics', [DBusString(type)],
replySignature: DBusSignature('a(dd)'));
var records = <UPowerDeviceStatisticsRecord>[];
var children = (result.returnValues[0] as DBusArray)
.children
.map((e) => e as DBusStruct);
for (var child in children) {
var values = child.children.toList();
var value = (values[0] as DBusDouble).value;
var accuracy = (values[1] as DBusDouble).value;
records.add(UPowerDeviceStatisticsRecord(value, accuracy));
}
return records;
}