-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Update layout tutorial for current best practices #9893
Conversation
Visit the preview URL for this PR (updated for commit 2e2eeb1): |
Test failure? |
The local run of the errored test went fine. @domesticmouse : Any hint as to why this went awry? |
You'll need to update your Flutter version to todays release to see the error. There was a bug in the analyzer in earlier Dart 3.2 versions that allowed |
examples/layout/base/lib/main.dart
Outdated
@@ -1,4 +1,4 @@ | |||
// Copyright 2021 The Flutter team. All rights reserved. | |||
// Copyright 2021-2023 The Flutter team. All rights reserved. |
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.
In the Flutter repo at least, we don't typically update the copyright dates. It's sufficient to include just the initial date.
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.
+1 for initial date only
Container( | ||
margin: const EdgeInsets.only(top: 8), | ||
Padding( | ||
padding: const EdgeInsets.only(top: 8), |
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.
Padding is different from margin, but that may be just fine. Padding is on the inside of the shape, and margin is on the outside. If the container doesn't have a color or decoration, then it really doesn't matter much.
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
_buildButtonColumn(color, Icons.call, 'CALL'), |
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.
You could probably also convert _buildButtonColumn into a separate StatelessWidget pretty easily. It only has those three parameters.
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.
I like that idea. I just did it.
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.
); | ||
} | ||
} | ||
// #enddocregion TextAdd |
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.
It looks like you have duplicate end doc region tags for TextAdd on line 11 and line 47. I have no idea how this interacts with the excerpter.
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.
It creates a // ...
break between the first #enddocregion
and the second #docregion
.
Also:
|
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.
I only left "food for thought" / non-blocking comments. LGTM
src/ui/layout/tutorial.md
Outdated
} | ||
``` | ||
|
||
## Diagram the layout |
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.
While I do prefer this updated version, I've always found this section of the page to be superfluous. Are readers really going to break out a pad of paper and draw a layout?
I can see an argument for why it's important, but I also think the truly valuable information here is in the annotated images, which could just be integrated into the steps themselves (starting with ## Add the title screen widget
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.
Yeah, I see that point and debated removing it myself, but getting the developer to stop and think about design before coding didn't see like a bad idea.
src/ui/layout/tutorial.md
Outdated
painted red, and the text "41". The entire row is in | ||
a `Container` and padded along each edge by 32 pixels. | ||
Add the title section to the app body like this: | ||
{:.numbered-code-notes} |
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.
@parlough Does this functionality exist on the Dart site? How easy is it to update with custom syntax in 11ty? Given that we're building a bigger tutorial (i.e. First Week Experience), I think this functionality is quite important and it'd be nice to consider whether we can (and should) "enhance it" with better syntax highlighting or some other way to annotate the code.
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.
@ericwindmill : You have no idea how often I want to add line numbers. In previous lifetimes, I would add them to anything longer than 10 lines.
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.
We don't have any standard functionality for this, but we could always implement something if people feel they will benefit from it. The main concern is accessibility and the ability for understanding to carry over to the explanations, so it would require a review of similar functionality out there today and any related accessibility concerns.
Generally (but not always) if a sample is so big that it needs multiple numbered explanations, it's best split up.
I'll do some research and keep this in mind as a use case to support!
Note I reverted this in #9927 to fix a few issues. There are potentially other small issues, but at least:
Please reopen and I'll complete a review. Thanks so much! |
This refactors the Layout Tutorial for current best practice including adding screenshots and using Padding where needed.
Fixes #2108
Fixes #1799
Fixes #9118