NativePlatformService class

Native (desktop) implementation of PlatformService.

Delegates every operation directly to dart:io. This file must never be imported on the web — use conditional imports via platform_init.dart.

Implemented types

Constructors

NativePlatformService()

Properties

currentDirectory String
Current working directory.
no setteroverride
environmentVariables Map<String, String>
All environment variables.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
homeDirectory String
User home directory (e.g. /Users/me).
no setteroverride
localHostname String
Local hostname.
no setteroverride
numberOfProcessors int
Number of processors available.
no setteroverride
operatingSystem String
Operating system identifier (e.g. macos, linux, windows, web).
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tempDirectory String
System temp directory.
no setteroverride

Methods

appendFile(String path, String content) Future<void>
Append content to the end of the file at path.
override
connectWebSocket(Uri url) Future<PlatformWebSocket>
Open a WebSocket connection to url.
override
copyFile(String source, String destination) Future<void>
Copy a file from source to destination.
override
createDirectory(String path, {bool recursive = true}) Future<void>
Create a directory at path.
override
createTempDirectory({String? prefix}) Future<String>
Create a temporary directory and return its path.
override
createTempFile({String? prefix, String? suffix}) Future<String>
Create a temporary file and return its path.
override
deleteDirectory(String path, {bool recursive = false}) Future<void>
Delete the directory at path. If recursive is true, delete contents.
override
deleteFile(String path) Future<void>
Delete the file at path.
override
directoryExists(String path) Future<bool>
Whether a directory exists at path.
override
fileExists(String path) Future<bool>
Whether a file exists at path.
override
httpRequest(String method, Uri url, {Map<String, String>? headers, Object? body, Duration? timeout}) Future<PlatformHttpResponse>
Perform an HTTP request.
override
listDirectory(String path, {bool recursive = false}) Future<List<String>>
List entries inside path. When recursive is true, descend into sub-directories.
override
moveFile(String source, String destination) Future<void>
Move / rename a file from source to destination.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readFile(String path) Future<String>
Read file at path as a UTF-8 string.
override
readFileBytes(String path) Future<Uint8List>
Read file at path as raw bytes.
override
runProcess(String executable, List<String> arguments, {String? workingDirectory, Map<String, String>? environment, Duration? timeout, bool runInShell = false}) Future<ProcessOutput>
Run a process to completion and capture its output.
override
startProcess(String executable, List<String> arguments, {String? workingDirectory, Map<String, String>? environment, bool runInShell = false}) Future<RunningProcess>
Start a long-running process and return a handle that exposes output streams and a kill method.
override
statFile(String path) Future<PlatformFileStat>
Return metadata for the entity at path.
override
toString() String
A string representation of this object.
inherited
watchDirectory(String path, {bool recursive = true}) Stream<FileChangeEvent>
Watch path for filesystem changes.
override
writeFile(String path, String content) Future<void>
Write content (UTF-8) to file at path, creating parent dirs as needed.
override
writeFileBytes(String path, Uint8List bytes) Future<void>
Write raw bytes to file at path, creating parent dirs as needed.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited