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');
  
  // ...
}

Libraries

os
Provides information about operating system.