getMeasurement method

  1. @override
Future<Measurement?> getMeasurement()
override

Subclasses should implement this method to collect a Measurement.

Can return null if no data is available. Can return an Error measurement if an error occurs.

Implementation

@override
Future<Measurement?> getMeasurement() async {
  await DeviceInfo().init();

  return Measurement.fromData(DeviceInformation(
    deviceData: DeviceInfo().deviceData,
    platform: DeviceInfo().platform,
    deviceId: DeviceInfo().deviceID,
    deviceName: DeviceInfo().deviceName,
    deviceModel: DeviceInfo().deviceModel,
    deviceManufacturer: DeviceInfo().deviceManufacturer,
    operatingSystem: DeviceInfo().operatingSystemName,
    hardware: DeviceInfo().hardware,
  ));
}