-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Proposal: A more complete app template for Flutter #76519
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
Conversation
|
Hi @Hixie, would you please have a look at this PR, and/or suggest other reviewers? This is the project that adds a more complete template ( We have a 24-page public document explaining all the micro-decisions that went into this. I recommend skimming through it since it may pre-empt some understandable questions and raised eyebrows. |
|
Sorry if this is in the linked docs, but what is the plan for testing this? Relatedly, I'm wondering if this could be an opportunity for demonstrating testing practices by including a few more non-trivial tests in the template itself. |
Is there a test for the current
Here's our thinking on this. In short: we see that, with the current template, developers introduce breaking changes to the template in the first 5 minutes of their work, and then the smoke test is broken (often statically broken, so there are analyzer errors and squiggly lines). The effect is that the (otherwise very educational!) Nothing here is set in stone, though. |
|
We need to find a way to not duplicate the existing platform files. We occasionally have to update these, and having 2 copies of everything is going to increase the chances that we accidentally get out of sync somewhere. |
|
|
packages/flutter_tools/templates/list_detail_app/analysis_options.yaml.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/main.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/app.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/app.dart.tmpl
Outdated
Show resolved
Hide resolved
...flutter_tools/templates/list_detail_app/lib/src/dummy_feature/dummy_item_list_view.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/settings/settings_controller.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/settings/settings_view.dart.tmpl
Outdated
Show resolved
Hide resolved
|
We should definitely have tests for this app since it's non-trivial. I agree they shouldn't be in the template. |
|
Thanks to everyone for the reviews! I'm working on addressing all feedback.
Could you please describe in a bit more detail what kind of tests you'd like to see? I was going to replicate the tests for the Counter app, but I can include additional Widget and/or Unit tests to cover the functionality of the app as well. Thanks again :) |
Well at a minimum we should verify that we can navigate to each page, and that changing the theme settings works. Might be good to have some golden tests too just in case. |
df1e7b7 to
2a28270
Compare
packages/flutter_tools/templates/list_detail_app/lib/src/app.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/app.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/app.dart.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/list_detail_app/lib/src/settings/settings_service.dart.tmpl
Outdated
Show resolved
Hide resolved
|
Thanks again for the review, everyone. I've gone through and updated the tool a bit to support the new template. Features include:
Please note: some tests will not pass until we merge flutter/packages#295. This is my first time modifying the CLI, so I'm not sure if this is the correct approach! Happy to change it up if need be. |
- Bump flutter_template_images to 2.0.0 - Fix typo in variable name
e0c3d3f to
397c577
Compare
|
Thanks everyone. I agree: There's no perfect name here, and I'm happy with skeleton as well :) I saw some updates were pushed to this branch, but they looked a bit busted. There should only be about ~900 additions, nowhere near 8000. Therefore, I've rebased my branch against master to be sure this PR is up-to-date, renamed everything to skeleton, and force-pushed once again. At this point, I think the plan for landing this PR seems to be:
|
zanderso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm w/ nit
I don't have a strong opinion about the name, but an advantage of 'skeleton_app' would be making it easier to think of the name for similar templates for modules and plugins: 'skeleton_module', 'skeleton_plugin', etc.
| /// It is different than the "module" template in that it exposes and doesn't | ||
| /// manage the platform code. | ||
| app, | ||
| /// A List/Detail app template that follows community best practices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it looks like this list was alphabetized.
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No strong opinion about the particular name. I do see advantages in using the suffix _app to make it clear what kind of template this is (e.g. module, plugin, package, or app).
|
cc @stuartmorgan re: the use of non-default templates using a naming convention like "skeleton_app" or "federated_plugin" as he's particularly interested in adding a federated plugin template in the future. |
|
I think it's plausible that we'll need a couple of new |
|
The reason I'm not 100% on board with I do understand the appeal of having a more stratified approach to naming. I just think we need to understand the tradeoff between that, and developer experience. |
|
Perhaps we could have a policy that non-app templates get the suffix, e.g. skeleton is an app template but instead of using federated, we use federated_plugin. |
|
We could also drop the underscore, as in "skeletonapp" |
|
Hey all -- not 100% sure where we stand with this one. Unfortunately, I do not have any more free time to dedicate to this PR. Therefore, I'll close this one out for now. Please feel free to pick it up if you'd like to continue with it! |
|
@brianegan what was left to do? wasn't it reviewed and ready to land? |
|
It was ready to roll with the old name or "skeleton," but from what I can gather the naming discussion has not come to a conclusion and the PR has become a bit stale. Therefore, to wrap up this work, the team needs to choose a name, update the template to support the new name, update the template to support null safety, and rebase the branch against master again as there are now conflicting changes. |
|
If someone is going to pick this up and drive it to completion please let me know soon, because otherwise flutter/packages#295 needs to be reverted as a second breaking change to that package. |
|
In general, this template has a ton of great practices in a very little bit of code. I'm looking forward to using it in my own projects. Here's a little bit of review feedback for @filiph as referenced to https://github.com/brianegan/new_flutter_template:
|
|
Thanks @csells, replies inline:
We were aware of the issue but decided to prioritize simplicity of code. What do you mean by mitigating the issue with a tooltip?
That would make the code a lot more complex, and isn't necessarily all that clear cut. Desktop apps often open a completely separate window for settings screens, which would make things even harder to implement.
We explored this. In many cases, AppBar will be meaningfully different between pages. This can be mitigated by creating a custom widget, of course, but that would make the template more complex. And it's something where we don't need to educate. The template educates about things like file structure, but extracting widget is something an intermediate developer is perfectly capable of. In short, this goes back to the goals of the template: getting out of the way of an intermediate/advanced developer.
That is intentional. In most apps we're seeing, app-level settings aren't accessible from everywhere. Of course, a desktop app has its settings in the menu, so in that sense, it's available everywhere. But again, this is something an intermediate developer should be able to implement themselves. And it allows us to save code that would otherwise need to be understood, modified and/or deleted by the developer.
This is also intentional. We've seen that developers, when starting projects, don't immediately implement i18n everywhere. It really damages perceived developer productivity when, instead of In the template, we show how to go about doing i18n in Flutter, and give you the files in the right places and with the right contents, but don't implement it fully for you. As a developer, you'd be deleting most of it anyway. |
|
ping @csells |
|
@filiph replies: re: mitigating with a tooltip: at least a tooltip would show if you move the mouse over in that direction, although obviously that's a pretty lame mitigation. I'm curious what feedback we get from a wider audience on the rest. Certainly what you have is a big improvement in pointing people down the right path structurally compared to the Counter app. |
|
Is there an updated PR to track work on this? |
|
Not yet. I'm planning to create it after next week (I/O). |
FYI @filiph the flutter/packages change got reverted flutter/packages#353. You'll need to re-land that in order to land the tool change. |
Given the experience last time, where the images package was left in an unusable state for several months, I would strongly prefer that the updated PR be fully approved and ready to land before doing the changes it the images package. It can be tested locally with version 2.0.0 of the package. |
|
Hey all, I'm unable to push changes to this PR for whatever reason, so I'm recreating it in #83530. That PR is ready for review. I'll ask folks over there. This PR can stay closed. |
Fixes #76379
Summary
I've worked with @filiph to develop a new template application that includes two features: A static list / detail feature and a dynamic settings feature. When a user changes the Theme in the settings screen, the application responds in kind.
The template takes the following notable approaches. Reasons behind each feature / approach is documented in the "New Flutter Template: Final Decisions" document.
Approach
Preview
simplescreenrecorder-2021-02-22_15.27.52.mp4
simplescreenrecorder-2021-02-26_17.11.23.mp4
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.