Open escamoteur opened 3 years ago
No problem, I've actually asked the same question as we've gone along :) Would be interested to hear opinions from others as well.
Personally, I think that there needs to be a more advanced default Flutter hello world app. Maybe not extremely different than the current one, but a bit more opinionated and configured (e.g. analysis options or file naming).
What really would be helpfull if you could turn any existing flutter project into a template so that you don't have to repeat your setup for every new project.
Regarding the app templating (i.e. changing app into a template), there's a very interesting project carried out by none other than @felangel called mason inspired by stagehand. With simple cli call mason make brick_name
you can create opinionated, prepopulated app, feature or package. You can host bricks wherever you want (e.g. private git repository) and configure them in dedicated mason.yaml
file.
The purpose of a template is for it to take care of the setup for us. So if what the template produces isn't what people want to use, why use a template at all?
And since in many areas there's more than one choice, I'm pretty sure that what we want is instead something with questions and checkboxes
Something like:
$ flutter create
> Type the app name
hello_world
> Do you want to enable null safety? Y/n
Y
> What package to use for state-management?
- [ ] provider
- [ ] bloc
- ...
> What router do you want to use?
- [ ] Navigator 1
- [ ] Navigator 2
> What CI do you want to use?
- Github Action
- Travis
- ...
- none
And this would be something community maintained
I'm pretty sure that what we want is instead something with questions and checkboxes
fwiw we're working on something very similar that is extensible and leverages mason internally to generate projects from templates given a configuration.
Thanks all! I don't discount the usefulness of a tool like mason
.
However, do you think this type of tool would address the needs of the target audience: Beginner-to-Intermediate flutter developers that have asked for concrete guidance on how to structure their apps?
Would such a tool provide enough concrete advice?
While I agree that a tool would be fantastic (and I hope it will come!) I also want to point out that there still needs to be some baseline β even if that baseline can be highly extensible and configurable. We may make it possible to select a state management approach, but the scaffold around it should (in my opinion) be shared. File structure, feature-versus-function, analysis_options.yaml
, etc. So this whole project is about that scaffold. If you imagine for a while that automation cannot be used, what template would you build?
And I'll be the first to admit that a template with automation in mind would look at least slightly differently than a template without automation in mind. But we need to start somewhere. Don't let perfect be the enemy of good.
However, do you think this type of tool would address the needs of the target audience: Beginner-to-Intermediate flutter developers that have asked for concrete guidance on how to structure their apps?
Would such a tool provide enough concrete advice?
It's likely out of scope for this particular project but it might be useful to take something like the flutter_architecture_samples and convert each sample to a template which can then be selected via a CLI as @rrousselGit suggested.
flutter create my_provider_app --architecture provider
This could be a small step in that direction which mason would help with. There would just need to be a script to convert the existing project code into a brick (which could be done as part of the CI). I'm happy to help with that if you think it would be worth pursuing but it does sound like it's out of scope for this particular project.
I agree with @filiph that having a generic baseline would be useful regardless π
If you imagine for a while that automation cannot be used, what template would you build?
Then I wouldn't build a template at all. Instead, I'd have numerous examples.
In the end, people can git clone existing examples. So open source apps already function as templates without automation.
I don't see the purpose of using templates if it isn't customisable.
As a learning source, examples are better because they can be more focused and advanced.
And when starting a new application, starting from scratch is far from bad in the Flutter ecosystem.
As opposed to other environments, we don't have to spend ages setting up webpack or other things. So a template is significantly less useful.
The only important part is the android/ios folders, which are already generated in the counter example.
Anything else would likely just be superfluous for many and will be deleted right after generation
That's especially true because a large number of things in the Flutter ecosystem have multiple competing solutions.
In end end, what is the purpose for creating a new template?
Because we already have a few of them.
As @felangel said, maybe what we want is instead a built-in way to list the available options for --sample
, such as flutter create hello_world --sample=widgets.SingleChildScrollView.1
?
I think that might just be dodging the hard dilemmas. From our studies, it's clear that a normal, everyday Flutter developer doesn't want to make these decisions themselves. They don't even want to choose from an extensive menu of wildly different sample apps.
A developer like you and I, we know what we want and we actually enjoy this kind of thing (to some level at least). But time and time again, we see that this is not the case for most others.
And again, even that extensive menu (which, again, I think should exist at some point in the future) should probably be based on some baseline. Or do you think that's not needed?
I understand the desire to not have to make decisions, but I don't think a template is a solution for that.
I haven't heard anyone complain about the default application. What I've seen is people complain that there are too many competing solutions to a problem, and a template does nothing for that.
The people I spoke with don't want an app. They want Google to take a clearer stance on "how" things needs to be done and write a style-guide similar to Effective Dart for Flutter, that covers areas such as routing/state-management/folder architecture.
Something like:
I think there is a need of a style guide that covers more complex topics like @rrousselGit pointed out. Personally, when I was learning state management and other more advance Flutter topics, I always ended up in community videos, blog posts and others. From this I noticed that Flutter developers, whilst sometimes having similar approaches they also had diverse views on how to tackle certain things, usually dependent on their specific needs.
I think an official style guide could be appreciated. Pointing out some well studied DO's and DON'T will give great guidance, specially if it is from an official source.
Similarly, regarding the new template. I do see a need for it. The current counter template was successful at showing the basics. When reading over different developers approaches there are obvious common patterns that all of them tend to end up doing (due to the nature of Flutter perhaps?). Like for example, grouping "screens", separating common widgets, including app theming, state management, etc. Whilst I think the template should not enforce massive restrictions I would find it useful if it avoids me writing some basic code and structure at the start of a new project. Maybe it also helps new developers to follow a similar path that builds upon this new template.
I would like to give a shout out to Super Declarative who is working on building Flutter Processing and making sketches, somewhat equivalent to @rrousselGit sample suggestion.
Thanks for the follow up feedback, everyone.
I understand the desire to not have to make decisions, but I don't think a template is a solution for that.
Could you see a style guide and template being part of a larger initiative with Code Labs and other documentation? I agree, folks "want Google to take a clearer stance on "how" things needs to be done," and a template is not enough to address that problem alone. But, I'd argue that a style guide isn't enough, either. From my experience running workshops and mentoring junior Flutter developers, many require more step-by-step guidance and instruction.
Therefore, I don't see a template as the endpoint, but as the beginning. If we can decide on a few "sane defaults" for Flutter apps, perhaps agreeing to some common terminology for patterns we're using, and put that advice into a template as a sound starting point. Then, augment that baseline template with code labs that explain how to add new features to the template with the recommended architecture, style guides, and perhaps even additional sample apps.
Furthermore, a simple baseline could be a good launching point for community tutorials discussing how to switch from ValueNotifier to Cubit or StateNotifier and what the advantages are.
What do you think of that kind of plan?
I don't quite agree with that feeling, because not everything has to be done by Google.
The community can create workshops/templates/documentations/examples/... There are numerous open source apps, articles,... On the other hand, only Google have the ability to make a Google certified style guide.
Furthermore, a simple baseline could be a good launching point for community tutorials discussing how to switch from ValueNotifier to Cubit or StateNotifier and what the advantages are.
But we already have your architecture sample for this. And the Flutter gallery is also a very good source of knowledge.
I don't see what a new project would add to those.
What the architecture sample would need is a really good explanation that is accessible from the Flutter.dev website
Hello guys!! Thank you for your nice discussion here. It is a lot of interesting conversation and I was inspired by https://github.com/brianegan/new_flutter_template/issues/15#issuecomment-768410447 comment with idea about tool for generating our project in interactive way.
So I think that it is a great idea so I created simple Flutter-Template-Generator project during this weekend for generating basic project from template and I hope it can be useful for anybody. ;)
There are only a few bash scripts which take predefined template and create a new Flutter project for you. I developed and tested it with Linux but I think you can run it also in MacOS or Windows with WSL enabled.
Now there are some default basic templates for the most common state managements and I have in the plan to add there also some other templates with various architecture, 3rd party libraries (for example with HiveDB or sqflite) or with some other else special things..
If you are interested in this project, here is a link and be free for any contribution ;)
Thank you everybody and have a nice day :)
I'm pretty sure that what we want is instead something with questions and checkboxes
fwiw we're working on something very similar that is extensible and leverages mason internally to generate projects from templates given a configuration.
We just released very_good_cli in case anyone wants to take a look π
βοΈ Thank you @felangel!
I don't want to discourage anyone, I'm just not sure if a new template will really help people who struggle in building an app.
IMHO providing people with information how to best structure their Flutter App in the sense of archtitecture and folder layout (Featurewise is so much better :-) ) is what people need to understand.
Then we can tell them what packages they can use to solve problems that you get when you start splitting up your logic, so that they than can select a one that makes the most sense to them.
@brianegan 's architecture samples (still awaits merging of RVMS π ) are still an incredible resource IMHO. What they lack is a detailed tutorial alongside and being directly accesible from the Flutter.de website.
Something similar with one or two recomended architectures using different technologies would be more helpful than trying to create one template.
What really would be helpfull if you could turn any existing flutter project into a template so that you don't have to repeat your setup for every new project.