MDeviceValue class

Reads a device metric in the widget process, so it is correct even when the app has not run for days.

It behaves exactly like an MBind — usable anywhere a bound value is accepted, including MProgressBar.value and MVisibility.bind:

MText(MDeviceValue(MDeviceMetric.batteryLevel))
MProgressBar(value: MDeviceValue(MDeviceMetric.batteryLevel), max: 100)
MVisibility(
  bind: MDeviceValue(MDeviceMetric.batteryCharging),
  child: const MIcon(sfSymbol: 'bolt.fill', androidDrawable: 'ic_lightning'),
)

An app-supplied battery level goes stale the moment the app is backgrounded; this does not. Only the metrics a widget actually references are collected.

Inheritance

Constructors

MDeviceValue(MDeviceMetric metric)

Properties

hashCode int
The hash code for this object.
no setterinherited
key String
finalinherited
metric MDeviceMetric
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited