I'm building a no-code test automation tool for Flutter and Flutter driver.
For Flutter driver to connect it needs the url of the Dart VM Service.
In Flutter this is reported as follows when running a debug build.
A Dart VM Service on sdk gphone64 arm64 is available at: http://127.0.0.1:56083/oOR_LvT4RT4=/
Over the past 3 years, the way this is reported has changed 4 times if I remember correctly.
I know because when it changes my software breaks .
This questions is to figure out if there's a way that I can query the device dart is running on to get the URL of an active Dart VM service.
I rely on regex now to get the URL out and it's more stable since I don't rely on things like "available at:" , but this is matching other urls that show up in the logs, that actually do match as well.
I would still like a more guaranteed URL retrieval implementation
The Dart VM service URL is available via the
app.debugPort
eventYou can get the Dart VM service URL for a running Flutter app reliably by listening to the
app.debugPort
event.The
app.debugPort
event is sent by theflutter daemon
server when a VM service port is available for a started app.The
app.debugPort
event is also exposed viaflutter run --machine
so you can start the app with the command and handle theapp.debugPort
event.More information:
Sample Message:
Here is a sample message for the
app.debugPort
event. The Dart VM service URL is contained in thewsUri
parameter.Sample Code:
From your tool, you can get the Dart VM service URL using the code below:
Note: The Shell object is available via the process_run package.
The console will print out this message: