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
Make InkDecoration not paint if the ink is not visible #122585
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 (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@goderbauer or @HansMuller before I work hard on polish, I'm interested in if you think this is a decent way to go about this. |
@override | ||
Widget build(BuildContext context) { | ||
List<Widget> wrappedChildren = List<Widget>.generate(children.length, (int i) { | ||
return Visibility( |
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.
To maintain the documented properties of the IndexedStack ("The stack is always as big as the largest child.") this must set maintainSize
to true.
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 hope we have a test that's failing because of this, if not, could you please add one?)
@@ -224,39 +224,46 @@ class Visibility extends StatelessWidget { | |||
/// objects, to be immediately created if [visible] is true). | |||
final bool maintainInteractivity; | |||
|
|||
static VisibilityMarker of(BuildContext context) { |
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.
Wondering: Should this just return true/false? Do you have any plans to extend VisibilityMarker? Or ideas what we should add in the future?
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.
Good point - returning a boolean is cleaner.
To fully evaluate this, it would be useful to see what it would take to get all tests to pass again. Are those just failing because of the |
Thanks @goderbauer! The failing tests were just due to the need to use |
Ok, @goderbauer I think this is ready for a real review. |
@@ -279,13 +279,15 @@ class _InkState extends State<Ink> { | |||
if (_ink == null) { | |||
_ink = InkDecoration( | |||
decoration: widget.decoration, | |||
isVisible: Visibility.of(context), |
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.
Can it be extended to parameters like boundaries
to solve these issues at the same time?
ping @goderbauer 🙂 |
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
bool get isVisible => _isVisible ?? true; | ||
bool? _isVisible; |
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 the fact that _isVisible is nullable is not really important? Maybe simplify to
bool get isVisible => _isVisible ?? true; | |
bool? _isVisible; | |
bool get isVisible => _isVisible; | |
bool _isVisible = true; |
auto label is removed for flutter/flutter, pr: 122585, due to - The status or check suite Linux firebase_abstract_method_smoke_test has failed. Please fix the issues identified (or deflake) before re-applying this label. |
This introduces a `isVisible` field in `InkDecoration` to control whether the decoration is painted. It also introduces a `Visibility.of()` method that can be used to determine the visibility state of widgets in the tree based on Visibility ancestry state. This then updates Ink to consult `Visibility.of()` and set the visible flag on its ink decoration accordingly. Finally, this updates `IndexedStack` to add a `Visibility` widget around each of the stack's children, so that non-visible children of the stack will be able to use `Visibility.of()` to know their visibility. Putting it all together, this means that ink no longer paints itself when it's in a non-selected index of an indexed stack. flutter#59963
Make InkDecoraiton not paint if the ink is not visible
This introduces a
isVisible
field inInkDecoration
to control whetherthe decoration is painted. It also introduces a
Visibility.of()
methodthat can be used to determine the visibility state of widgets in the tree
based on Visibility ancestry state. This then updates Ink to consult
Visibility.of()
and set the visible flag on its ink decorationaccordingly.
Finally, this updates
IndexedStack
to add aVisibility
widget aroundeach of the stack's children, so that non-visible children of the stack
will be able to use
Visibility.of()
to know their visibility.Putting it all together, this means that ink no longer paints itself when
it's in a non-selected index of an indexed stack.
#59963
Pre-launch Checklist
///
).