Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:io
  3. Platform class
Platform
description

Platform classabstractfinal

Information about the environment in which the current program is running.

Platform provides information such as the operating system,the hostname of the computer, the value of environment variables,the path to the running program,and other global properties of the program being run.

Get the URI of the current Dart script

Use thescript getter to get the URI to the currently runningDart script.

import 'dart:io' show Platform;void main() {  // Get the URI of the script being run.  var uri = Platform.script;  // Convert the URI to a path.  var path = uri.toFilePath();}

Get the value of an environment variable

Theenvironment getter returns a the names and values of environmentvariables in aMap that contains key-value pairs of strings. The Map isunmodifiable. This sample shows how to get the value of thePATHenvironment variable.

import 'dart:io' show Platform;void main() {  Map<String, String> envVars = Platform.environment;  print(envVars['PATH']);}

Determine the OS

You can get the name of the operating system as a string with theoperatingSystem getter. You can also use one of the static booleangetters:isMacOS,isLinux,isWindows, etc.

import 'dart:io' show Platform;void main() {  // Get the operating system as a string.  String os = Platform.operatingSystem;  // Or, use a predicate getter.  if (Platform.isMacOS) {    print('is a Mac');  } else {    print('is not a Mac');  }}

Properties

hashCodeint
The hash code for this object.
no setterinherited
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()String
A string representation of this object.
inherited

Operators

operator ==(Objectother)bool
The equality operator.
inherited

Static Properties

environmentMap<String,String>
The environment for this process as a map from string key to string value.
no setter
executableString
The path of the executable used to run the script in this isolate.Usuallydart when running on the Dart VM or thecompiled script name (script_name.exe).
no setter
executableArgumentsList<String>
The flags passed to the executable used to run the script in this isolate.
no setter
isAndroidbool
Whether the operating system is a version ofAndroid.
final
isFuchsiabool
Whether the operating system is a version ofFuchsia.
final
isIOSbool
Whether the operating system is a version ofiOS.
final
isLinuxbool
Whether the operating system is a version ofLinux.
final
isMacOSbool
Whether the operating system is a version ofmacOS.
final
isWindowsbool
Whether the operating system is a version ofMicrosoft Windows.
getter/setter pair
lineTerminatorString
The current operating system's default line terminator.
no setter
localeNameString
Get the name of the current locale.
no setter
localHostnameString
The local hostname for the system.
final
numberOfProcessorsint
The number of individual execution units of the machine.
final
operatingSystemString
A string representing the operating system or platform.
final
operatingSystemVersionString
A string representing the version of the operating system or platform.
final
packageConfigString?
The--packages flag passed to the executable used to run the scriptin this isolate.
no setter
pathSeparatorString
The path separator used by the operating system to separatecomponents in file paths.
final
resolvedExecutableString
The path of the executable used to run the script in thisisolate after it has been resolved by the OS.
no setter
scriptUri
The absolute URI of the script being run in this isolate.
no setter
versionString
The version of the current Dart runtime.
final
  1. Dart
  2. dart:io
  3. Platform class
dart:io library

[8]ページ先頭

©2009-2025 Movatter.jp