Passing command line arguments to a flutter app

1.5k Views Asked by At

Is package:args ArgParser compatible with flutter apps? I see on Github that it is used several times in some Flutter tools, but I'm not sure it's used in any of the sample apps.

If it is not compatible, is there another way to pass configuration options to my app at compile time as part of its build rule?

1

There are 1 best solutions below

0
On BEST ANSWER

package:args operates on List<String>, which can come from anywhere. For example, I've used it in a browser app, in which the arguments came from Chrome's JS console. If you are OK with using the HostMessages API, then the following might work for you:

On Android, turn Intent.getExtras into List<String> and pass it to package:args. Similarly, this answer may help on the iOS side.