os

Last updated:

0 purchases

os Image
os Images
Add to Cart

Description:

os

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
copied to clipboard
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}');
}
copied to clipboard
Detect development/production environment #

isRunningInDebugMode

Is the code running in debug mode?


isRunningInProfileMode

Is the code running in a profile mode?


isRunningInReleaseMode

Is the code running in a release mode?


isRunningInTest

Is the code running in a test?



Determine platform properties #

isRunningInFlutter

Is the code running in a Flutter application?


isRunningInJs

Is the code running in a Javascript engine?


isRunningInWeb

Is the code running in a web browser?



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');

// ...
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.