The flutter create command has a number of option flags that can be set to control its output. It would be useful to be able to set those from the New Project command:
Specifically org and description are ones that I never leave to their default values, and selecting a template is useful for quick-starting non-app projects.
A potential issue here is that vscode doesn't allow us to use advanced dialogs to prompt for user input, so we're limited to one prompt at a time.This means we can't use a single form, and each item we want to request from the user will add yet another dialog step.
It also means we can't hide advanced options from new users who might not want to worry about them just yet.
Perhaps we could add a New Project (Advanced) command which would prompt for all fields and default on empty? That still means every single option gets prompted for even if you just want to set the name and org.
Implementation details:
As I understand it this is how new projects are created:
Flutter: New Project from the command palette.folder/namefolder/nameSo passing in more options would add a complication in that it isn't easy to pass that data across windows for the actual create command to use.
Would it be viable to call flutter create _before_ opening the new window? That would allow us to provide the options directly based on the user's input, without having to find a mechanism to pass it across windows. It would also mean that we're now opening a new vscode window in a flutter project folder, which should load the extension automagically without requiring a temp/trigger file.
UX proposal for multiple inputs:
Rather than popup an input dialog for each option, Flutter: New Project (Advanced) could open an editor tab with a generated config/json [containing the defaults], which the user can then edit to set their own values. Saving this file would trigger the create command.
```json
{
"template": "app",
"description": "A new Flutter project.",
"org": "com.example",
"pub": true,
"offline": false,
"with-driver-test": false,
"ios-language": "objc",
"android-language": "java"
}
I'm interested in contributing a PR to implement this, but looking for feedback [especially on how best to present it/prompt the user for input].
Perhaps we could add a
New Project (Advanced)command
This could work, but I do think we need to be careful not to clutter the palette with too many (these ones appear even without a Dart project open - even currently to users without a Flutter SDK that might never do Flutter).
I'm not all that familiar with the options for flutter create so I don't know how frequently each are used (or how important it is that they're set up front - for ex. I presume editing the description is easy to do later, but changing the Android language is not).
cc @devoncarew @mit-mit for thoughts/opinions... Do you think any of the other options are useful enough to put into the current flow? Do you think we should consider a second command (this may tie in with #508 which at least would reduce exposure to those opting-in to the Flutter extension).
So passing in more options would add a complication in that it isn't easy to pass that data across windows for the actual create command to use.
We actually don't run flutter run until we've loaded the new folder, so in theory the additional prompts could wait till then (though I don't know how it'd feel):
flutter createWould it be viable to call flutter create before opening the new window?
We originally did that, but we thought it'd work nicer if your folder was open while it was running the long-running operation (and the output panel can then hang around for the user to see rather than disappearing in front of them)
Rather than popup an input dialog for each option,
Flutter: New Project (Advanced)could open an editor tab with a generated config/json
This feels a bit clunky to me - the purpose of this command is to make things quick and simple, but making users edit a json file doesn't feel that way - especially if they have to look up what the exact language IDs are (or we'd have to contribute some completion).
Hey, some thoughts:
flutter create that generates the main project type captures most of the user casesflutter create, flutter create --template=plugin, and flutter create --template=package) - these could be done via two additional commands. I'm not sure of the value of this over just the simplicity of a single Flutter Create commandI think we should resolve #508 first. If we end up with a Flutter extension I'd feel much more comfortable adding an additional command or two, because it wouldn't show up for people that haven't opted-in to Flutter and are just doing Dart.
Another possibility is adding a setting for the user to set their preferred language/org and using that. They wouldn't be able to customise it per-invocation, but at least they could set it somewhere and then still use the functionality.
I think we should add settings for people to put their preferences for most of these in (so they can use this command even if they don't want all defaults, but we don't need to add a load of steps). But in the case of things we should probably ask for (like org), we could prompt the first time and put it in a setting, then pre-fill from the setting the next time. This way although it's an extra prompt, people will generally be able to just hit
@devoncarew @mit-mit WDYT?
I've added three new settings:
dart.flutterCreateOrganizationdart.flutterCreateIOSLanguagedart.flutterCreateAndroidLanguageThe first is a string, the other two enums. These can be set in your user settings, and will be passed to flutter create.
I don't think it makes sense to have description as an option since it'll change from project to project. I'm on the fence about whether we should prompts during creation. The command was aimed at new users and I think asking them to enter a reverse domain for their company when they're probably creating a throwaway test app makes getting started less straight forward.
I think probably we should ship just with these options for now and see if it covers most cases, and we can refine later. So, I'm gonna close this with the work I've done; but do feel free to open additional issues if you think we need more and we can revisit for a future release.
Most helpful comment
I've added three new settings:
dart.flutterCreateOrganizationdart.flutterCreateIOSLanguagedart.flutterCreateAndroidLanguageThe first is a string, the other two enums. These can be set in your user settings, and will be passed to
flutter create.I don't think it makes sense to have description as an option since it'll change from project to project. I'm on the fence about whether we should prompts during creation. The command was aimed at new users and I think asking them to enter a reverse domain for their company when they're probably creating a throwaway test app makes getting started less straight forward.
I think probably we should ship just with these options for now and see if it covers most cases, and we can refine later. So, I'm gonna close this with the work I've done; but do feel free to open additional issues if you think we need more and we can revisit for a future release.