core_runtime library Core

Platform agnostic utilities for retrieving information about the current platform.

A Runtime provides functions for retrieving the current platform's information. Unlike dart:io Platform, Runtime works on both native and web. The information includes the operating system name & version on native, and the browser information on web. The browser information may not be accurate since it is derived from the User-Agent header.

// Assuming that the current platform is Android.
print(const Runtime().android); true
print(const Runtime().web); false

A FakeRuntime is also provided for testing.

print(const FakeRuntime(PlatformType.android).android); true
print(const FakeRuntime(PlatformType.android).web); false

Classes

FakeRuntime
Creates a FakeRuntime for testing.
Runtime
Provides a platform agnostic way to retrieve information about the platform.

Enums

PlatformType
The platform's type.