Repository navigation
Description
It would be interesting to enable the creation of custom templates usable with flutter create, which don't require that the templates be actually in our repo. For example, if Rive wanted to create a template that showed off how to use Rive animations in Flutter, they could do so without having to land code in the flutter/flutter repo. (VGV have done something similar: https://verygood.ventures/blog/flutter-starter-app-very-good-core-cli)
Should we enable anyone to create a template, or should we have an allowlist? There's a risk of people tricking people into running hostile code if we allow anyone to host templates. We could have two tiers, one for template sets whose creators we trust, and one which gets a big warning.
How do we identify templates? We could do it by URL, or by some well-established pattern e.g. domain:path, like example.com:demoapp which expands to example.com/.flutter-templates/demoapp.zip or some such.
How do we host templates? zip files?
How do we avoid having to include redundant files? e.g. it'd be nice if most templates could be just lib/main.dart and pubspec.yaml.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsPlanned Q3
- StatusShow more project fieldsNo status
Activity
jonahwilliams commentedon Mar 3, 2021
Some thoughts:
Many kinds of templates have tags/conditionals, but I'm not sure how either the CLI or Flutter IDEs would provide those without a lowest common denominator approach like
--template-value=foo=barIf most templates don't want to deal with platform configuration, then we'd need to include that by default. If we start supporting custom platform configurations, we'd need to account for them when writing migrators https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/base/project_migrator.dart#L15
tarobins commentedon Mar 3, 2021
A specific template I'd like, which would be probably a way I'd use this feature, is to have a template like the app starter template but without all the comments, and maybe not even some of the code.
When I want to just quickly try something in flutter, I end up creating and app and then deleting a bunch of the comments and some of the code cause that just clutters up my experiment work. Not saying the comments aren't good; they are very helpful for a new users, but I'd rather flutter create an even more bare-bones app in some cases.
[added] It would also be super helpful if I could host this template somewhere other than my local machine cause I often do flutter experiments on different machines, so I'd like to just point at some url. I realize this feature could introduce a whole load of security issues, so maybe not feasible, but anyway. Though maybe the security issue is no different than a pub package?
pedromassangocode commentedon Mar 3, 2021
I agree. Something like
flutter create foo --no-commentswould be great.Hixie commentedon Mar 5, 2021
I hadn't thought of using
pubto host these, that's brilliant. It would reduce all the problems here to a previously solved problem. (Or at least, a previously-existing problem.)@jonahwilliams, regarding tags/conditionals, can you elaborate? What tags and conditionals do we use in the current templates? I suspect it might be ok to not support this generally for the new templates but I am not sure if I'm missing something obvious.
jonahwilliams commentedon Mar 5, 2021
For example, suppose your template generates a test file alongside your project. Its generally the case that we use package imports for test files, so the import would need to configured based on the chosen project name.
Hixie commentedon Mar 5, 2021
I guess the question is whether we need such flags beyond a standard set like "project name".
AliHG commentedon Mar 5, 2021
Are these templates gonna contain guide lines for app architecture and state management like in Jetpack MVVM ??
AliHG commentedon Mar 5, 2021
@Hixie I saw your talk in flutter engage but i don't know if this is what you meant or not
Hixie commentedon Mar 5, 2021
They could, but the one I mentioned during the Q&A is actually in review right now and wouldn't use this (it would just be built in). That should land soon and should be in the next stable.
YazeedAlKhalaf commentedon Apr 22, 2021
I agree with having custom templates, like a place for user-defined templates. For example, I use an architecture called Stacked, most of the time I just copy and paste code which is annoying when starting a new project. If I could for example run
flutter create --template stacked my_awesome_flutter_app. It would make creating projects way easier! 🚀The templates could be in some site just like
pub.devwhere people publish their own templates and share them with the people. Though there should be some limitations so it does not get spammed. Or maybe use GitHub repos for templates 🤔.I suggest allowing only trusted people and also the template should be reviewed by some designated people before being recommended to the people. And also there could be a way for custom templates if the user wants to use his own template 😉
Hixie commentedon Apr 22, 2021
Yeah, using pub.dev seems like the best proposal so far. We could literally just have these be a special kind of package: you run
flutter create --from-package foobarand it fetches and expands thefoobarpackage from pub. Might make sense for these to be an overlay on top of the existing templates so that people can just include the parts they want.22 remaining items
omishah commentedon Sep 20, 2023
this is really an important feature that should be available 👍
flutter-triage-bot commentedon Nov 25, 2023
This issue is assigned to @christopherfujino but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
flutter-triage-bot commentedon Feb 5, 2024
This issue was assigned to @christopherfujino but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.
Likhachev17 commentedon May 17, 2024
tananga commentedon Oct 8, 2024
This is a great idea! If I can build app based on skeleton template I also should be able to create my own custom template
spydon commentedon Apr 14, 2025
I agree that this would be a great idea! Our use-case would be to provide a simple Flame template with a skeleton for our Flame Game Jam (or just in general), instead of having to use third-party tools like Mason or Ignite.