BatteryManager extension type

The BatteryManager interface of the Battery Status API provides information about the system's battery charge level. The navigator.getBattery method returns a promise that resolves with a BatteryManager interface.

Since Chrome 103, the BatteryManager interface of Battery Status API only expose to secure context.


API documentation sourced from MDN Web Docs.

on
Implemented types
Available extensions

Properties

charging bool
The charging read-only property of the BatteryManager interface is a Boolean value indicating whether or not the device's battery is currently being charged. When its value changes, the BatteryManager.chargingchange_event event is fired.
no setter
chargingTime double
The chargingTime read-only property of the BatteryManager interface indicates the amount of time, in seconds, that remain until the battery is fully charged, or 0 if the battery is already fully charged or the user agent is unable to report the battery status information. If the battery is currently discharging, its value is Infinity. When its value changes, the BatteryManager.chargingtimechange_event event is fired.
no setter
dischargingTime double
The dischargingTime read-only property of the BatteryManager interface indicates the amount of time, in seconds, that remains until the battery is fully discharged, or Infinity if the battery is currently charging rather than discharging or the user agent is unable to report the battery status information. When its value changes, the BatteryManager.dischargingtimechange_event event is fired.
no setter
hashCode int
The hash code for this object.
no setterinherited
level double
The level read-only property of the BatteryManager interface indicates the current battery charge level as a value between 0.0 and 1.0. A value of 0.0 means the battery is empty and the system is about to be suspended. A value of 1.0 means the battery is full or the user agent is unable to report the battery status information. When its value changes, the BatteryManager.levelchange_event event is fired.
no setter
onchargingchange EventHandler?
getter/setter pair
onchargingtimechange EventHandler?
getter/setter pair
ondischargingtimechange EventHandler?
getter/setter pair
onlevelchange EventHandler?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addEventListener(String type, EventListener? callback, [JSAny options]) → void
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
inherited
dispatchEvent(Event event) bool
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEventListener(String type, EventListener? callback, [JSAny options]) → void
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
inherited
toString() String
A string representation of this object.
inherited

Operators

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