StartCommand class

Spawns flutter run -d <device> detached, scrapes the VM Service URI from stdout, writes ~/.artisan/state.json for downstream consumers.

Supports --device flag (default chrome). For non-chrome targets the --web-port flag is omitted (flutter rejects it on desktop/mobile). URI scrape regex matches both web and desktop/mobile stdout formats:

  • Web: Debug service listening on ws://127.0.0.1:8181/<token>/ws
  • Desktop/mobile: A Dart VM Service on <Platform> is available at: http://127.0.0.1:<port>/<token>/ Desktop/mobile http://... URIs are normalized to ws://.../ws.

The optional --cdp-port=N flag enables a CDP-aware Chrome launch:

  1. Validates the Flutter SDK is at or above 3.30.0 (the version that activates --web-experimental-hot-reload for -d web-server per flutter/flutter#170612).
  2. Resolves a Chrome binary path (macOS bundle or Linux PATH).
  3. Pre-launches Chrome detached with --remote-debugging-port=N, --remote-allow-origins=*, and a dedicated --user-data-dir.
  4. Probes the debug port to confirm Chrome is reachable.
  5. Runs flutter run -d web-server --web-port=<port> --web-experimental-hot-reload (silent remap from --device=chrome because the chrome target would auto-launch its own conflicting Chrome).
  6. Waits for the web-server log line "is being served at" so the URL is bound before any client attempts to connect.
  7. Navigates the pre-launched Chrome to the served URL via CDP Page.navigate. DWDS only emits "Debug service listening on ..." AFTER a debugger client connects, so the navigate must happen BEFORE the VM Service scrape; scraping first would deadlock the handshake (see commit 871d0a7).
  8. Scrapes the VM Service URI from the flutter run log (DWDS prints the "Debug service listening on ..." line once Chrome connected).
  9. Writes chromePid, cdpPort, and tmpProfileDir to the state file so StopCommand can reap Chrome on teardown.

D6 Chrome reaper (POSIX, chrome target only) defers to V1.x; V1 ships the basic spawn + URI scrape + state.json write.

Inheritance

Constructors

StartCommand()

Properties

boot CommandBoot
What boot context the dispatcher must establish before calling handle. See CommandBoot for the V1 taxonomy (none, connected).
no setteroverride
description String
One-line description (rendered in artisan list next to name).
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
name String
Dispatch key. Colons (:) act as namespace prefixes for artisan list grouping (e.g. dusk:snap groups under dusk).
no setteroverride
parsedSignature CommandSignature?
Lazy-parsed signature. Cached for the lifetime of the instance.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
signature String?
Optional Laravel-style signature DSL. When set, name derives from it and configure auto-registers the declared options/flags.
no setterinherited

Methods

configure(ArgParser parser) → void
Auto-applies signature to the parser when set. Override to register extra ArgParser features (mandatory options, aliases, custom value validators). When you override, call super.configure(parser) first if you also use the signature DSL.
override
handle(ArtisanContext ctx) Future<int>
Execute the command. Returns the process exit code.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

cdpChromeBinaryResolver CdpChromeBinaryResolver
Test seam: Chrome binary resolver.
getter/setter pair
cdpChromeNavigator CdpChromeNavigator
Test seam: Chrome Page.navigate (default opens a CDP WebSocket).
getter/setter pair
cdpChromeProber CdpChromeProber
Test seam: Chrome /json/version probe (default duplicates the fluttersdk_dusk ChromeFinder algorithm inline to avoid an inverted cross-package dependency).
getter/setter pair
cdpFifoMaker CdpFifoMaker?
Test seam: replaces mkfifo (no-op in tests; production stays POSIX-pure).
getter/setter pair
cdpProcessRunner CdpProcessRunner
Test seam: Process.run replacement (flutter --version probe, mkfifo).
getter/setter pair
cdpProcessStarter CdpProcessStarter
Test seam: Process.start replacement (Chrome + flutter wrapper).
getter/setter pair
cdpTmpProfileDirRoot String?
Test seam: tmp profile dir root (default /tmp).
getter/setter pair
cdpVmServiceScraper CdpVmServiceScraper?
Test seam: VM Service URI scraper. When null, the production _scrapeVmServiceUriFromFile is used.
getter/setter pair
cdpWebServerReadyWaiter CdpWebServerReadyWaiter?
Test seam: web-server readiness waiter. When null, the production _waitForWebServerReady polls the log file for the "is being served at" marker; tests inject an instant-return fake.
getter/setter pair
defaultChromeBinary String? Function(String? envOverride)
Resolves the Chrome binary path: macOS canonical bundle, then Linux PATH lookup. Returns null on Windows or when neither candidate exists. envOverride is reserved for V1.x DUSK_CHROME_BIN; currently ignored.
no setter
defaultChromeNavigate Future<void> Function(int, String)
Production Chrome Page.navigate: HTTP /json/version + WebSocket connect
no setter
defaultChromeProbe Future<void> Function(int, Duration)
Production Chrome probe: polls /json/version with retry on SocketException, throws on HTTP 404 or timeout. Inline duplicate of fluttersdk_dusk's ChromeFinder.probe algorithm (avoids inverted cross-package dependency).
no setter

Static Methods

compareSemver(String a, String b) int
Compares two semver-ish strings by numeric segments only. Strips dev / build suffixes (everything after the first -). Returns negative if a < b, 0 if equal, positive if a > b. Pads missing segments with 0 so 3.30 compares equal to 3.30.0.
normalizeVmServiceUri(String raw) String
resolveChromeBinary({required bool isMacOs, required bool isLinux, required bool macAppExists(String), required String? pathLookup(String)}) String?
Pure resolver for testability: macOS bundle path, Linux PATH google-chrome, otherwise null. Injects platform booleans and lookup functions so the real Platform / File / which dependencies stay out of unit tests.