Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing command line arguments to a flutter app

Tags:

flutter

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?

like image 848
Dave Shuckerow Avatar asked Dec 29 '16 00:12

Dave Shuckerow


1 Answers

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.

like image 118
Yegor Avatar answered Oct 26 '22 01:10

Yegor