FakeDeviceService class

In-memory DeviceService returning fixed device lists.

Records launched, shutdown and deleted calls so tests can assert on routing.

Implemented types

Constructors

FakeDeviceService({List<Device> simulators = const [], List<Device> physical = const [], bool available = true})
Creates a fake listing simulators and physical devices.

Properties

available ↔ bool
Returned by isAvailable.
getter/setter pair
deleted → List<String>
Device ids passed to deleteSimulator, in order.
final
hashCode → int
The hash code for this object.
no setterinherited
launched → List<({List<String> args, String deviceId, bool headless})>
Recorded launchDevice calls, in order.
final
physical ↔ List<Device>
Returned by getPhysicalDevices.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shutdown → List<String>
Device ids passed to shutdownSimulator, in order.
final
simulators ↔ List<Device>
Returned by getSimulators.
getter/setter pair
wiped → List<String>
Device ids passed to wipeData, in order.
final

Methods

deleteSimulator({required String deviceId}) → Future<bool>
Permanently deletes a shut-down simulator/emulator. Returns whether it was deleted.
override
emitDeviceChange() → void
Simulates the platform reporting a device change on watchDevices.
getPhysicalDevices() → Future<List<Device>>
Connected physical devices (phones, tablets, watches, …).
override
getSimulators() → Future<List<Device>>
Emulators / simulators known to the platform SDK.
override
isAvailable() → Future<bool>
Whether the platform tooling is installed and responding.
override
launchDevice({required String deviceId, List<String> additionalArgs = const [], bool headless = false}) → Future<void>
Boots or starts deviceId, passing additionalArgs to the launcher.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shutdownSimulator({required String deviceId}) → Future<bool>
Shuts down a simulator/emulator. Returns whether the command succeeded.
override
toString() → String
A string representation of this object.
inherited
watchDevices() → Stream<void>
Fires whenever devices may have appeared, disappeared or changed state, so callers re-read getSimulators / getPhysicalDevices instead of polling. Each listen starts the platform watchers and cancelling stops them. Events come in bursts: debounce before reloading. Empty when the platform cannot be watched.
override
wipeData({required String deviceId}) → Future<bool>
Erases a shut-down simulator/emulator's user data (apps, settings, snapshots), like a factory reset. Returns whether it was wiped.
override

Operators

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