Dart Documentationchrome.powerChromePower

ChromePower class

class ChromePower extends ChromeApi {
 static final JsObject _power = chrome['power'];

 ChromePower._();

 bool get available => _power != null;

 /**
  * Requests that power management be temporarily disabled. [level] describes
  * the degree to which power management should be disabled. If a request
  * previously made by the same app is still active, it will be replaced by the
  * new request.
  */
 void requestKeepAwake(Level level) {
   if (_power == null) _throwNotAvailable();

   _power.callMethod('requestKeepAwake', [jsify(level)]);
 }

 /**
  * Releases a request previously made via requestKeepAwake().
  */
 void releaseKeepAwake() {
   if (_power == null) _throwNotAvailable();

   _power.callMethod('releaseKeepAwake');
 }

 void _throwNotAvailable() {
   throw new UnsupportedError("'chrome.power' is not available");
 }
}

Extends

ChromeApi > ChromePower

Properties

final bool available #

Returns true if the API is available. The common causes of an API not being avilable are:

  • a permission is missing in the application's manifest.json file
  • the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi
bool get available => _power != null;

Methods

void releaseKeepAwake() #

Releases a request previously made via requestKeepAwake().

void releaseKeepAwake() {
 if (_power == null) _throwNotAvailable();

 _power.callMethod('releaseKeepAwake');
}

void requestKeepAwake(Level level) #

Requests that power management be temporarily disabled. level describes the degree to which power management should be disabled. If a request previously made by the same app is still active, it will be replaced by the new request.

void requestKeepAwake(Level level) {
 if (_power == null) _throwNotAvailable();

 _power.callMethod('requestKeepAwake', [jsify(level)]);
}