New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable custom "flutter create" templates #77104
Comments
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 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 |
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? |
I agree. Something like |
I hadn't thought of using @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. |
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. |
I guess the question is whether we need such flags beyond a standard set like "project name". |
Are these templates gonna contain guide lines for app architecture and state management like in Jetpack MVVM ?? |
@Hixie I saw your talk in flutter engage but i don't know if this is what you meant or not |
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. |
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 The templates could be in some site just like
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 |
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 |
I imagine more lines have been collectively deleted from the counter app than have gone into any other single codebase. :) |
Following, I would also like to see this. My goal would be to have a way to set up a template project with files, folders, structure, packages maybe even initial routing that can be generated via a command line like Yoman in JS. Reduce the boilerplate of setup, currently working on my 6th app in Flutter. |
The functionality you're describing is very similar to what we have done in very_good_cli and regarding the template creation and generation we use package:mason. With mason developers are able to bundle their templates which would make it easier to publish a single template bundle to pub.dev rather than multiple files/directories. We would love to work together on this if you think it makes sense |
@felangel thanks |
@felangel any tutorials on how you did this |
FYI we just published a blog post on mason |
@Hixie I'd love to work together on this if that's a possibility. It would be awesome to have first-party support for templates as part of the pub ecosystem! |
If you are interested in implementing this please feel free to jump in! For something like this it's probably a good idea to write a design doc first; see https://github.com/flutter/flutter/wiki/Chat#design-documents. |
And to @Hixie 's point on a design doc - this isn't really a formality. I am personally not convinced that custom create templates in the flutter tool add a lot of value over a new tool like the very_good_cli. You should be prepared to make the case that isn't true, and to additionally explain how it would be maintained without breaking as the tool libraries/source update over time. |
Just wanted to give an update... I've been actively working on package:mason and package:mason_cli over the last year to make it easy for developers to define/consume reusable templates. With I would love to collaborate with the Flutter team to leverage an open source tool like |
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 toexample.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.
The text was updated successfully, but these errors were encountered: