Skip to content
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

Merged
merged 10 commits into from
Dec 13, 2023

Conversation

atsansone
Copy link
Contributor

@atsansone atsansone commented Dec 4, 2023

This refactors the Layout Tutorial for current best practice including adding screenshots and using Padding where needed.

Fixes #2108
Fixes #1799
Fixes #9118

@flutter-website-bot
Copy link
Collaborator

flutter-website-bot commented Dec 4, 2023

Visit the preview URL for this PR (updated for commit 2e2eeb1):

https://flutter-docs-prod--pr9893-fix-2108-1db4ypog.web.app

@domesticmouse
Copy link
Contributor

Test failure?

@atsansone
Copy link
Contributor Author

The local run of the errored test went fine. @domesticmouse : Any hint as to why this went awry?

image

@parlough
Copy link
Member

parlough commented Dec 6, 2023

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 const when it shouldn't have. I have a fix in #9901

@@ -1,4 +1,4 @@
// Copyright 2021 The Flutter team. All rights reserved.
// Copyright 2021-2023 The Flutter team. All rights reserved.
Copy link
Contributor

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.

Copy link
Contributor

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),
Copy link
Contributor

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'),
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

);
}
}
// #enddocregion TextAdd
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@domesticmouse
Copy link
Contributor

Also:

warning • Unused import: 'package:flutter/foundation.dart' • test/widget_test.dart:4:8 • unused_import

@parlough parlough added the review.copy Awaiting Copy Review label Dec 10, 2023
@atsansone atsansone removed the request for review from ericwindmill December 11, 2023 05:00
@atsansone atsansone removed the review.tech Awaiting Technical Review label Dec 11, 2023
Copy link
Contributor

@ericwindmill ericwindmill left a 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

}
```

## Diagram the layout
Copy link
Contributor

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

Copy link
Contributor Author

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.

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}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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!

@atsansone atsansone merged commit d93a46c into flutter:main Dec 13, 2023
9 checks passed
@atsansone atsansone added st.RFM Ready to merge or land and removed review.copy Awaiting Copy Review labels Dec 13, 2023
parlough added a commit that referenced this pull request Dec 14, 2023
@parlough
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
st.RFM Ready to merge or land
Projects
None yet
7 participants