os 1.0.1 copy "os: ^1.0.1" to clipboard
os: ^1.0.1 copied to clipboard

API for information about the operating system and the environment. Works in all platforms, including browsers.

Pub Package package publisher

Introduction #

This Dart package that provides information about the operating system and the build environment. The package is designed to work in all platforms, including browsers.

Getting started #

In pubspec.yaml:

dependencies:
  os: ^1.0.0

APIs #

Operating system detection #

OperatingSystemType.current detects operating system in all platforms (including browsers):

Example:

import 'package:os/os.dart';

void main() {
  final operatingSystem = OperatingSystem.current;
  print('Operating system: $operatingSystem');
  print('Operating system is by Apple: ${operatingSystem.isCupertino}');
}

Detect development/production environment #

Determine platform properties #

Add test tear down functions #

The package does not introduce a dependency on "package:test", but it is still able to detect a test environment and add "tearDown" functions that will be run after the test.

Use TestEnvironment.current

import 'package:os/test_environment.dart';

void doSomething() {
  // ...
  
  TestEnvironment.current?.addTearDown(() {
    // ...
  });
  TestEnvironment.current?.printOnFailure('Some information');
  
  // ...
}
5
likes
150
points
161
downloads

Publisher

verified publisherdint.dev

Weekly Downloads

API for information about the operating system and the environment. Works in all platforms, including browsers.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

More

Packages that depend on os