Skip to content

Navigator ​

Annotations: @Native.new("Navigator")

Inheritance

Object → NavigatorConcurrentHardware → Navigator

Properties ​

appCodeName no setter override ​

String get appCodeName
Implementation
dart
String get appCodeName native;

appName no setter override ​

String get appName
Implementation
dart
String get appName native;

appVersion no setter override ​

String get appVersion
Implementation
dart
String get appVersion native;

budget no setter ​

_BudgetService? get budget
Implementation
dart
_BudgetService? get budget native;

clipboard no setter ​

_Clipboard? get clipboard
Implementation
dart
_Clipboard? get clipboard native;

connection no setter ​

NetworkInformation? get connection
Implementation
dart
NetworkInformation? get connection native;

cookieEnabled no setter override ​

bool? get cookieEnabled
Implementation
dart
@Unstable()
bool? get cookieEnabled native;

credentials no setter ​

CredentialsContainer? get credentials
Implementation
dart
CredentialsContainer? get credentials native;

dartEnabled no setter override ​

bool? get dartEnabled
Implementation
dart
bool? get dartEnabled native;

deviceMemory no setter ​

num? get deviceMemory
Implementation
dart
num? get deviceMemory native;

doNotTrack no setter ​

String? get doNotTrack
Implementation
dart
String? get doNotTrack native;

geolocation no setter ​

Geolocation get geolocation
Implementation
dart
@Unstable()
Geolocation get geolocation native;

hardwareConcurrency no setter inherited ​

int? get hardwareConcurrency

Inherited from NavigatorConcurrentHardware.

Implementation
dart
int? get hardwareConcurrency native;

hashCode no setter inherited ​

int get hashCode

Inherited from Interceptor.

Implementation
dart
int get hashCode => Primitives.objectHashCode(this);

language no setter override ​

String get language
Implementation
dart
String get language =>
    JS('String', '#.language || #.userLanguage', this, this);

languages no setter override ​

List<String>? get languages
Implementation
dart
List<String>? get languages native;

maxTouchPoints no setter ​

int? get maxTouchPoints
Implementation
dart
int? get maxTouchPoints native;

mediaCapabilities no setter ​

MediaCapabilities? get mediaCapabilities
Implementation
dart
MediaCapabilities? get mediaCapabilities native;

mediaDevices no setter ​

MediaDevices? get mediaDevices
Implementation
dart
MediaDevices? get mediaDevices native;

mediaSession no setter ​

MediaSession? get mediaSession
Implementation
dart
MediaSession? get mediaSession native;

mimeTypes no setter ​

MimeTypeArray? get mimeTypes
Implementation
dart
MimeTypeArray? get mimeTypes native;

nfc no setter ​

_NFC? get nfc
Implementation
dart
_NFC? get nfc native;

onLine no setter override ​

bool? get onLine
Implementation
dart
@Unstable()
bool? get onLine native;

permissions no setter ​

Permissions? get permissions
Implementation
dart
Permissions? get permissions native;

persistentStorage no setter ​

DeprecatedStorageQuota? get persistentStorage
Implementation
dart
@JSName('webkitPersistentStorage')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
DeprecatedStorageQuota? get persistentStorage native;

platform no setter override ​

String? get platform
Implementation
dart
String? get platform native;

presentation no setter ​

Presentation? get presentation
Implementation
dart
Presentation? get presentation native;

product no setter override ​

String get product
Implementation
dart
@Unstable()
String get product native;

productSub no setter ​

String? get productSub
Implementation
dart
@Unstable()
String? get productSub native;

runtimeType no setter inherited ​

Type get runtimeType

Inherited from Interceptor.

Implementation
dart
Type get runtimeType =>
    getRuntimeTypeOfInterceptorNotArray(getInterceptor(this), this);

serviceWorker no setter ​

ServiceWorkerContainer? get serviceWorker
Implementation
dart
ServiceWorkerContainer? get serviceWorker native;

storage no setter ​

StorageManager? get storage
Implementation
dart
StorageManager? get storage native;

temporaryStorage no setter ​

DeprecatedStorageQuota? get temporaryStorage
Implementation
dart
@JSName('webkitTemporaryStorage')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
DeprecatedStorageQuota? get temporaryStorage native;

userAgent no setter override ​

String get userAgent
Implementation
dart
String get userAgent native;

vendor no setter ​

String get vendor
Implementation
dart
@Unstable()
String get vendor native;

vendorSub no setter ​

String get vendorSub
Implementation
dart
@Unstable()
String get vendorSub native;

vr no setter ​

VR? get vr
Implementation
dart
VR? get vr native;

webdriver no setter override ​

bool? get webdriver
Implementation
dart
bool? get webdriver native;

Methods ​

cancelKeyboardLock() ​

void cancelKeyboardLock()
Implementation
dart
void cancelKeyboardLock() native;

getBattery() ​

Future<dynamic> getBattery()
Implementation
dart
Future getBattery() => promiseToFuture(JS("", "#.getBattery()", this));

getGamepads() ​

List<Gamepad?> getGamepads()
Implementation
dart
List<Gamepad?> getGamepads() {
  var gamepadList = _getGamepads();

  &#47;&#47; If no prototype we need one for the world to hookup to the proper Dart class.
  var jsProto = JS('', '#.prototype', gamepadList);
  if (jsProto == null) {
    JS('', '#.prototype = Object.create(null)', gamepadList);
  }

  applyExtension('GamepadList', gamepadList);
  return gamepadList;
}

getInstalledRelatedApps() ​

Future<RelatedApplication> getInstalledRelatedApps()
Implementation
dart
Future<RelatedApplication> getInstalledRelatedApps() =>
    promiseToFuture<RelatedApplication>(
      JS("creates:RelatedApplication;", "#.getInstalledRelatedApps()", this),
    );

getUserMedia() ​

Future<MediaStream> getUserMedia({dynamic audio = false, dynamic video = false})

Gets a stream (video and or audio) from the local computer.

Use MediaStream.supported to check if this is supported by the current platform. The arguments audio and video default to false (stream does not use audio or video, respectively).

Simple example usage:

dart
window.navigator.getUserMedia(audio: true, video: true).then((stream) {
  var video = new VideoElement()
    ..autoplay = true
    ..src = Url.createObjectUrlFromStream(stream);
  document.body.append(video);
});

The user can also pass in Maps to the audio or video parameters to specify mandatory and optional constraints for the media stream. Not passing in a map, but passing in true will provide a MediaStream with audio or video capabilities, but without any additional constraints. The particular constraint names for audio and video are still in flux, but as of this writing, here is an example providing more constraints.

dart
window.navigator.getUserMedia(
    audio: true,
    video: {'mandatory':
               { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 },
            'optional':
               [{ 'minFrameRate': 60 },
                { 'maxWidth': 640 }]
});

See also:

Implementation
dart
@SupportedBrowser(SupportedBrowser.CHROME)
Future<MediaStream> getUserMedia({audio = false, video = false}) {
  var completer = new Completer<MediaStream>();
  var options = {'audio': audio, 'video': video};
  _ensureGetUserMedia();
  this._getUserMedia(
    convertDartToNative_SerializedScriptValue(options),
    (stream) {
      completer.complete(stream);
    },
    (error) {
      completer.completeError(error);
    },
  );
  return completer.future;
}

getVRDisplays() ​

Future<dynamic> getVRDisplays()
Implementation
dart
Future getVRDisplays() =>
    promiseToFuture(JS("creates:VRDisplay;", "#.getVRDisplays()", this));

noSuchMethod() inherited ​

dynamic noSuchMethod(Invocation invocation)

Invoked when a nonexistent method or property is accessed.

A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:

dart
dynamic object = 1;
object.add(42); // Statically allowed, run-time error

This invalid code will invoke the noSuchMethod method of the integer 1 with an Invocation representing the .add(42) call and arguments (which then throws).

Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.

A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:

dart
class MockList<T> implements List<T> {
  noSuchMethod(Invocation invocation) {
    log(invocation);
    super.noSuchMethod(invocation); // Will throw.
  }
}
void main() {
  MockList().add(42);
}

This code has no compile-time warnings or errors even though the MockList class has no concrete implementation of any of the List interface methods. Calls to List methods are forwarded to noSuchMethod, so this code will log an invocation similar to Invocation.method(#add, [42]) and then throw.

If a value is returned from noSuchMethod, it becomes the result of the original invocation. If the value is not of a type that can be returned by the original invocation, a type error occurs at the invocation.

The default behavior is to throw a NoSuchMethodError.

Inherited from Interceptor.

Implementation
dart
dynamic noSuchMethod(Invocation invocation) {
  throw NoSuchMethodError.withInvocation(this, invocation);
}

registerProtocolHandler() ​

void registerProtocolHandler(String scheme, String url, String title)
Implementation
dart
@Unstable()
void registerProtocolHandler(String scheme, String url, String title) native;

requestKeyboardLock() ​

Future<dynamic> requestKeyboardLock([List<String>? keyCodes])
Implementation
dart
Future requestKeyboardLock([List<String>? keyCodes]) {
  if (keyCodes != null) {
    List keyCodes_1 = convertDartToNative_StringArray(keyCodes);
    return _requestKeyboardLock_1(keyCodes_1);
  }
  return _requestKeyboardLock_2();
}

requestMediaKeySystemAccess() ​

Future<dynamic> requestMediaKeySystemAccess(
  String keySystem,
  List<Map<dynamic, dynamic>> supportedConfigurations,
)
Implementation
dart
Future requestMediaKeySystemAccess(
  String keySystem,
  List<Map> supportedConfigurations,
) => promiseToFuture(
  JS(
    "creates:MediaKeySystemAccess;",
    "#.requestMediaKeySystemAccess(#, #)",
    this,
    keySystem,
    supportedConfigurations,
  ),
);

requestMidiAccess() ​

Future<dynamic> requestMidiAccess([Map<dynamic, dynamic>? options])
Implementation
dart
@JSName('requestMIDIAccess')
Future requestMidiAccess([Map? options]) {
  var options_dict = null;
  if (options != null) {
    options_dict = convertDartToNative_Dictionary(options);
  }
  return promiseToFuture(
    JS("", "#.requestMIDIAccess(#)", this, options_dict),
  );
}

sendBeacon() ​

bool sendBeacon(String url, Object? data)
Implementation
dart
bool sendBeacon(String url, Object? data) native;

share() ​

Future<dynamic> share([Map<dynamic, dynamic>? data])
Implementation
dart
Future share([Map? data]) {
  var data_dict = null;
  if (data != null) {
    data_dict = convertDartToNative_Dictionary(data);
  }
  return promiseToFuture(JS("", "#.share(#)", this, data_dict));
}

toString() inherited ​

String toString()

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.

Inherited from Interceptor.

Implementation
dart
String toString() => Primitives.objectToHumanReadableString(this);

Operators ​

operator ==() inherited ​

bool operator ==(Object other)

The equality operator.

The default behavior for all Objects is to return true if and only if this object and other are the same object.

Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw.

  • Reflexive: For all objects o, o == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must be true.

The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.

If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.

Inherited from Interceptor.

Implementation
dart
bool operator ==(Object other) => identical(this, other);