Skip to content

Enable custom "flutter create" templates #77104

Open

Description

@Hixie

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.

Activity

  1. added
    c: new featureNothing broken; request for a new capability
    toolAffects the "flutter" command-line tool. See also t: labels.
    P3Issues that are less important to the Flutter project
    on Mar 2, 2021
  2. jonahwilliams commented on Mar 3, 2021

    @jonahwilliams
    Contributor

    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=bar

    If 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

  3. tarobins commented on Mar 3, 2021

    @tarobins
    Contributor

    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?

  4. pedromassangocode commented on Mar 3, 2021

    @pedromassangocode

    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.

    I agree. Something like flutter create foo --no-comments would be great.

  5. Hixie commented on Mar 5, 2021

    @Hixie
    ContributorAuthor

    Though maybe the security issue is no different than a pub package?

    I hadn't thought of using pub to 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.

  6. jonahwilliams commented on Mar 5, 2021

    @jonahwilliams
    Contributor

    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.

  7. Hixie commented on Mar 5, 2021

    @Hixie
    ContributorAuthor

    I guess the question is whether we need such flags beyond a standard set like "project name".

  8. AliHG commented on Mar 5, 2021

    @AliHG

    Are these templates gonna contain guide lines for app architecture and state management like in Jetpack MVVM ??

  9. AliHG commented on Mar 5, 2021

    @AliHG

    @Hixie I saw your talk in flutter engage but i don't know if this is what you meant or not

  10. Hixie commented on Mar 5, 2021

    @Hixie
    ContributorAuthor

    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.

  11. YazeedAlKhalaf commented on Apr 22, 2021

    @YazeedAlKhalaf
    Contributor

    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.dev where 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 🤔.

    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.

    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 😉

  12. Hixie commented on Apr 22, 2021

    @Hixie
    ContributorAuthor

    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 foobar and it fetches and expands the foobar package 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.

  13. 22 remaining items

  14. omishah commented on Sep 20, 2023

    @omishah

    this is really an important feature that should be available 👍

  15. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Nov 25, 2023
  16. flutter-triage-bot commented on Nov 25, 2023

    @flutter-triage-bot

    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!

  17. flutter-triage-bot commented on Feb 5, 2024

    @flutter-triage-bot

    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.

  18. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Feb 5, 2024
  19. Likhachev17 commented on May 17, 2024

    @Likhachev17
  20. tananga commented on Oct 8, 2024

    @tananga

    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

  21. spydon commented on Apr 14, 2025

    @spydon
    Contributor

    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.

  22. added
    tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.
    on Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamwould require significant investmentA PR would not be accepted without a plan for ongoing support

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions