Skip to content

AppleWatchBattery

Battery data from the Apple Watch.

Inheritance
Annotations

Constructors

AppleWatchBattery.fromJson

AppleWatchBattery.fromJson(
  1. Map<String, dynamic> json
)

AppleWatchBattery.fromRecord

AppleWatchBattery.fromRecord(
  1. Map<String, dynamic> record
)

Create an AppleWatchBattery from an AWARE ios_watch_battery record.

Note that AWARE stores the battery level as a fraction (0.0-1.0), which is converted to percent (0-100) here.

AppleWatchBattery

AppleWatchBattery({
  1. String? deviceId,
  2. DateTime? timestamp,
  3. String? label,
  4. int batteryLevel = -1,
  5. WatchBatteryState batteryState = WatchBatteryState.unknown,
})

Properties

batteryLevel

int batteryLevel
getter/setter pair

The battery level of the watch in percent (0-100).

Note that watchOS reports the battery level in steps of 5%. Is -1 if the level is unknown, e.g., when battery monitoring is disabled.

batteryState

WatchBatteryState batteryState
getter/setter pair

The charging state of the watch battery.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

jsonType

String get jsonType
override

Return the __type to be used for JSON serialization of this class. Default is runtimeType. Only specify this if you need another type.

Methods

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.