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
- 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.
import 'package:os/test_environment.dart';
void doSomething() {
// ...
TestEnvironment.current?.addTearDown(() {
// ...
});
TestEnvironment.current?.printOnFailure('Some information');
// ...
}
Libraries
- os
- Provides information about operating system.