Add a --dart-entrypoint-args flag to flutter run to pass through Dart entrypoint arguments on Flutter Desktop#69607
Conversation
jonahwilliams
left a comment
There was a problem hiding this comment.
I would suggest adding this to the debuggingOptions object -
The plumbing for where to send this is already complete, and it will not require any g3fixes to roll into google3
… entrypoint arguments on Flutter Desktop
c86c9d1 to
af85926
Compare
| ) | ||
| ..addMultiOption('dart-entrypoint-args', | ||
| abbr: 'a', | ||
| help: 'Pass a list of arguments to the Dart entrypoint at application ' |
There was a problem hiding this comment.
I would connect this more strongly with main(List<String> args), dart entrypoint is a bit vague. I think Dart calls this the "main function".
There was a problem hiding this comment.
The Dart entrypoint can be any name, the default is main. I will clarify that it's main() by default though.
There was a problem hiding this comment.
I guess we might have made the configurable in our embedder? But Dart says it is only main()
| abbr: 'a', | ||
| help: 'Pass a list of arguments to the Dart entrypoint at application ' | ||
| 'startup. Specify this option multiple times each with one argument ' | ||
| 'to pass multiple arguments to the Dart entrypoint.'); |
There was a problem hiding this comment.
Document that this is only support on desktop platforms (which ones).
| } | ||
|
|
||
| List<String> command = <String>[ executable, ]; | ||
| if (debuggingOptions?.dartEntrypointArgs != null) { |
There was a problem hiding this comment.
can dartEntrypointArgs be null here?
you can do this a bit more Dart-y with a spread:
final Process process = await _processManager.start(
<String>[
executable,
...?debuggingOptions?.dartEntrypointArgs,
]
(...)
)
| this.startPaused = false, | ||
| this.disableServiceAuthCodes = false, | ||
| this.disableDds = false, | ||
| this.dartEntrypointArgs, |
There was a problem hiding this comment.
A default value for each would be nice this.dartEntrypointArgs = const <String>[]
|
is there any example code to show how to use this to do |
… entrypoint arguments refer to: flutter/flutter#69607
|
If we have this flag in the shared runner, it would be nice if it worked for all platforms. (I tried it for Android, and it doesn't do anything). |
Description
Adds a --dart-entrypoint-args multioption to flutter run.
Related Issues
#32986
Tests
I added the following tests:
startApp supports dartEntrypointArgsChecklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
N/A to flutter_tools