PlatformServices class abstract
Abstract interface for platform-specific services.
This allows LuaDardo to run on both native and web platforms by abstracting away dart:io dependencies.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isNative → bool
-
Whether this is running on a native platform.
no setter
- isWeb → bool
-
Whether this is running on a web platform.
no setter
- pathSeparator → String
-
Get the platform's path separator.
no setter
- printCallback ↔ void Function(String)
-
Custom print callback. Can be overridden to redirect output.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- supportsFileSystem → bool
-
Whether file system operations are supported.
no setter
- supportsProcess → bool
-
Whether process operations are supported.
no setter
Methods
-
defaultPrint(
String s) → void - Print a string using the default mechanism for this platform.
-
deleteFile(
String path) → bool - Delete a file at the given path. Returns true if successful, false otherwise.
-
directoryExists(
String path) → bool - Check if a directory exists at the given path.
-
exit(
int code) → Never - Exit the application with the given code. Throws UnsupportedError on platforms that don't support this.
-
fileExists(
String path) → bool - Check if a file exists at the given path.
-
getEnvironmentVariable(
String name) → String? - Get an environment variable value. Returns null if not available or not supported on this platform.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
println(
String s) → void - Print a string followed by a newline.
-
readFileAsBytes(
String path) → Uint8List? - Read a file as bytes. Returns null if file doesn't exist or reading fails.
-
readFileAsString(
String path) → String? - Read a file as a string. Returns null if file doesn't exist or reading fails.
-
renameFile(
String oldPath, String newPath) → bool - Rename a file from oldPath to newPath. Returns true if successful, false otherwise.
-
runProcess(
String command, List< String> args) → int? - Run a process synchronously. Returns the exit code, or null if not supported.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → PlatformServices
-
Get the singleton instance of platform services.
Automatically initializes if not already done.
no setter
Static Methods
-
init(
PlatformServices services) → void - Initialize the platform services with a custom implementation. This is optional - if not called, a default implementation will be used.
-
reset(
) → void - Reset the platform services instance (useful for testing).