-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Add sample code to Offstage #65550
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
Add sample code to Offstage #65550
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Hi @ny927 and thanks for the contribution! I think we should try to take this a step further, since the sample code does not exactly show an example of |
@shihaohong Thank you for letting me know. I changed it to show the example of |
Hi @ny927 can you take a look at the failing checks here? It looks like the sample has errors in it. |
/// Offstage( | ||
/// offstage: !_offstage, | ||
/// child: Column( | ||
/// children: <Widget>[ | ||
/// RaisedButton( | ||
/// child: const Text('Get Size Of The Invisible Logo'), | ||
/// onPressed: () { _getInvisibleLogoSize(); }, | ||
/// ), | ||
/// Text('${_invisibleLogoSize ?? ''}'), | ||
/// ], | ||
/// ), | ||
/// ), |
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.
This particular widget doesn't have to be offstage, does it? My assumption is that you're trying to demonstrate that we can get the size of FlutterLogo
, even when it is offstage.
I think a better example could be something like so:
- We have an Offstage widget, much like yours, containing a widget (
FlutterLogo
) of a certain size. - Have a button to toggle offstage, just to demonstrate what happens visually when offstage is set to true/false.
- Have a text widget toggles to display the following:
if offstage is false, show
"FlutterLogo widget is not currently offstage,
so it is painted, available for hit testing, and painted."
if offstage is true, show
"FlutterLogo widget is offstage.
It is laid out in the widget tree, but occupies no space visually,
cannot be hit tested, and is not painted. Yet, we are able to get its
size as if it were painted: ${logoSize}"
/// class OffstageLogo extends StatefulWidget { | ||
/// @override | ||
/// _OffstageLogoState createState() => _OffstageLogoState(); | ||
/// } | ||
/// | ||
/// class _OffstageLogoState extends State<OffstageLogo> { |
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.
This section isn't necessary (lines 2676 to 2681) because the template you're using already assumes a stateful widget (you can immediately start from the contents of your stateful widget).
See the logs here for details: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket.appspot.com/8868703876011722080/+/steps/prepare_environment/0/steps/Analyze/0/steps/analyze/0/stdout
@ny927 Do you have plans to follow-up on this PR? |
(PR triage): I am going to close this one for now due to inactivity. Feel free to re-open when you find the time to work on it again. |
Description
Offstage didn't have sample code, so I added it.
Related Issues
Fixes #62737
Tests
N/A. Only the doc changed.
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].