-
Notifications
You must be signed in to change notification settings - Fork 149
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
waitUntilVisible() fails on Columns with SizedBox #2463
Comments
While the pull request will fix the problem on the given example, the overall problem seems to be bigger: The hitTestable will fail, even with Alignments, if we hit some "empty" space. In the example, the test will pass because we can get a result on The Pull Request might be an enhancement, up to your decision. But i would recommend to update the Documentation and clarify, that a finder with byKey or byClass should not be used on Complex Widgets with Paddings, Columns inside itself or it's children. At least if you want to check the visibility. It should be set on lowest child inside the widget tree. Setting the Key as in this example (though this is what i want to check, if ElementB is visible), will fail. With or without alignments: class ElementB extends StatelessWidget {
ElementB() : super(key: Keys.elementB);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(24.0),
child: const Column(
children: [
Text(
'Element B',
),
SizedBox(height: 48),
Text('Some other widget'),
],
),
);
}
} Instead you should set the key on a lower element to make sure that hitTestable() works: class ElementB extends StatelessWidget {
ElementB({super.key})
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(24.0),
child: const Column(
key: Keys.elementB // <- here with the PR merged
children: [
Text(
'Element B',
key: Keys.elementB // <- or here without the PR
),
SizedBox(height: 48),
Text('Some other widget'),
],
),
);
}
} As most "Newbies" like me would probably say "Yeah, let's go for visible and not for exist when we check the Widgets", it would perhaps help to clarify that All in all, thank you very much for this library and maybe i am just addressing some old stuff for experts that has already been widely discussed. But i ran into it and it really made me, not understanding "why" it was not visible though i could see it on the screen. :) |
I have found an answer on why the
waitUntilVisible()
test fails when using a Key or searching by Class. It has to do with the Widget containing a Column with a SizedBox.this will be found when calling
$(Keys.elementA).waitUnitilVisible()
:this will NOT be found when calling
$(Keys.elementB).waitUnitilVisible()
or$(ElementB).waitUntilVisible()
:I have created a reproducable example: Patrol Bug Finder Example
Originally posted by @FritzMatthaeus in #2459 (comment)
The text was updated successfully, but these errors were encountered: