Facilities for overriding various APIs of dart:io with mock
implementations.
This abstract base class should be extended with overrides for the
operations needed to construct mocks. The implementations in this base class
default to the actual dart:io implementation. For example:
class MyDirectory implements Directory {
...
// An implementation of the Directory interface
...
}
void main() {
IOOverrides.runZoned(() {
...
// Operations will use MyDirectory instead of dart:io's Directory
// implementation whenever Directory is used.
...
}, createDirectory: (String path) => new MyDirectory(path));
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stderr → Stdout
-
The standard output stream of errors written by this program.
no setter
- stdin → Stdin
-
The standard input stream of data read by this program.
no setter
- stdout → Stdout
-
The standard output stream of data written by this program.
no setter
Methods
-
createDirectory(
String path) → Directory -
Creates a new Directory object for the given
path. -
createFile(
String path) → File -
Creates a new File object for the given
path. -
createLink(
String path) → Link -
Returns a new Link object for the given
path. -
exit(
int code) → Never - Exit the Dart VM process immediately with the given exit code.
-
fseGetType(
String path, bool followLinks) → Future< FileSystemEntityType> -
Asynchronously returns the FileSystemEntityType for
path. -
fseGetTypeSync(
String path, bool followLinks) → FileSystemEntityType -
Returns the FileSystemEntityType for
path. -
fseIdentical(
String path1, String path2) → Future< bool> -
Asynchronously returns
trueifpath1andpath2are paths to the same file system object. -
fseIdenticalSync(
String path1, String path2) → bool -
Returns
trueifpath1andpath2are paths to the same file system object. -
fsWatch(
String path, int events, bool recursive) → Stream< FileSystemEvent> - Returns a Stream of FileSystemEvents.
-
fsWatchIsSupported(
) → bool -
Returns
truewhen FileSystemEntity.watch is supported. -
getCurrentDirectory(
) → Directory - Returns the current working directory.
-
getSystemTempDirectory(
) → Directory - Returns the system temporary directory.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serverSocketBind(
dynamic address, int port, {int backlog = 0, bool v6Only = false, }) → Future< ServerSocket> - Asynchronously returns a ServerSocket that connects to the given address and port when successful.
-
setCurrentDirectory(
String path) → void -
Sets the current working directory to be
path. -
socketConnect(
dynamic host, int port, {dynamic sourceAddress, int sourcePort = 0, Duration? timeout}) → Future< Socket> - Asynchronously returns a Socket connected to the given host and port.
-
socketStartConnect(
dynamic host, int port, {dynamic sourceAddress, int sourcePort = 0}) → Future< ConnectionTask< Socket> > - Asynchronously returns a ConnectionTask that connects to the given host and port when successful.
-
stat(
String path) → Future< FileStat> -
Asynchronously returns FileStat information for
path. -
statSync(
String path) → FileStat -
Returns FileStat information for
path. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- current → IOOverrides?
-
no setter
- global ← IOOverrides?
-
The IOOverrides to use in the root Zone.
no getter
Static Methods
-
runWithIOOverrides<
R> (R Function() body, IOOverrides overrides) → R -
Runs
bodyin a fresh Zone using the overrides found inoverrides. -
runZoned<
R> (R Function() body, {Directory Function(String)? createDirectory, Directory Function()? getCurrentDirectory, void Function(String)? setCurrentDirectory, Directory Function()? getSystemTempDirectory, File Function(String)? createFile, Future< FileStat> Function(String)? stat, FileStat Function(String)? statSync, Future<bool> Function(String, String)? fseIdentical, bool Function(String, String)? fseIdenticalSync, Future<FileSystemEntityType> Function(String, bool)? fseGetType, FileSystemEntityType Function(String, bool)? fseGetTypeSync, Stream<FileSystemEvent> Function(String, int, bool)? fsWatch, bool Function()? fsWatchIsSupported, Link Function(String)? createLink, Future<Socket> Function(dynamic, int, {dynamic sourceAddress, int sourcePort, Duration? timeout})? socketConnect, Future<ConnectionTask< Function(dynamic, int, {dynamic sourceAddress, int sourcePort})? socketStartConnect, Future<Socket> >ServerSocket> Function(dynamic, int, {int backlog, bool v6Only})? serverSocketBind, Stdin Function()? stdin, Stdout Function()? stdout, Stdout Function()? stderr, Never Function(int)? exit}) → R -
Runs
bodyin a fresh Zone using the provided overrides.