isBrowser top-level property

bool get isBrowser

Whether running in a web browser.

Identified by operatingSystem being the string browser.

If so, the operatingSystemVersion is the string made available through window.navigator.appVersion.

The value is true when the code is running inside a browser, no matter which operating system the browser is itself running on. No attempt is made to detect the underlying operating system. That information may be derived from operatingSystemVersion, but browsers are able to lie in the app-version/user-agent string.

Implementation

@pragma('vm:prefer-inline')
bool get isBrowser => OperatingSystem.current.isBrowser;