-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Make sure that a ListTile doesn't crash in 0x0 environment #176176
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 sure that a ListTile doesn't crash in 0x0 environment #176176
Conversation
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.
Code Review
This pull request adds a regression test to ensure that ListTile does not crash when rendered in a zero-sized area. My review includes a suggestion to make the test more comprehensive by covering more ListTile configurations to prevent future regressions.
| testWidgets('ListTile does not crash at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| const MaterialApp( | ||
| home: Scaffold( | ||
| body: Center(child: SizedBox.shrink(child: ListTile())), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(ListTile)), Size.zero); | ||
| }); |
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 test is a good start for ensuring ListTile behaves correctly in a zero-sized environment. However, it only covers the case of an empty ListTile. The layout logic for ListTile can be more complex when it includes leading, trailing, or title widgets.
To make this test more robust and prevent future regressions, I suggest expanding it to cover these cases as well. A table-driven approach could be effective here.
testWidgets('ListTile does not crash at zero area', (WidgetTester tester) async {
final List<Widget> listTiles = <Widget>[
const ListTile(),
const ListTile(title: Text('title')),
const ListTile(leading: Icon(Icons.add)),
const ListTile(trailing: Icon(Icons.remove)),
const ListTile(leading: Icon(Icons.add), trailing: Icon(Icons.remove)),
];
for (final Widget listTile in listTiles) {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(child: SizedBox.shrink(child: listTile)),
),
),
);
expect(tester.getSize(find.byType(ListTile)), Size.zero, reason: 'Failed for $listTile');
}
});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
dkwingsmt
left a comment
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.
Checklist:
- The test is in the correct file
- The test name goes “does not crash at zero area”
- The target widget is wrapped by
Center(or is fullscreen) - The target widget does not have an overlay, or the overlay is tested
- The target widget is expected to have a size of exactly
Size.zero
|
There are still leftover comments. |
a1ce792 to
3e19f3b
Compare
flutter/flutter@891d7d5...2d34167 2025-10-20 vegorov@google.com Cleanup create_updated_flutter_deps.py a bit (flutter/flutter#177162) 2025-10-20 jessy.yameogo@gmail.com Fixed hot reload/restart crashes after closing browser tab on web-server device (flutter/flutter#177026) 2025-10-20 engine-flutter-autoroll@skia.org Roll Skia from 0a3ace6fde82 to ed4294faecde (2 revisions) (flutter/flutter#177249) 2025-10-20 bruno.leroux@gmail.com Add DropdownMenu.decorationBuilder (flutter/flutter#176264) 2025-10-20 engine-flutter-autoroll@skia.org Roll Skia from 05e2f42f533d to 0a3ace6fde82 (1 revision) (flutter/flutter#177242) 2025-10-20 engine-flutter-autoroll@skia.org Roll Skia from 89abc5393317 to 05e2f42f533d (1 revision) (flutter/flutter#177238) 2025-10-20 koji.wakamiya@gmail.com [ios][engine] Fix autofill context cleanup and view lifecycle management (flutter/flutter#173598) 2025-10-20 rajveer0malviya@gmail.com Fix Image.network not using cache when headers are specified (flutter/flutter#176831) 2025-10-19 engine-flutter-autoroll@skia.org Roll Dart SDK from a66f334fee2a to 2cd2106f2cef (4 revisions) (flutter/flutter#177190) 2025-10-19 engine-flutter-autoroll@skia.org Roll Skia from 2d424175a481 to 89abc5393317 (1 revision) (flutter/flutter#177235) 2025-10-19 ahmedsameha1@gmail.com Make sure that a ListTile doesn't crash in 0x0 environment (flutter/flutter#176176) 2025-10-19 ahmedsameha1@gmail.com Make sure that a DropdownButton doesn't crash in 0x0 environment (flutter/flutter#174880) 2025-10-19 engine-flutter-autoroll@skia.org Roll Skia from 899155871d29 to 2d424175a481 (1 revision) (flutter/flutter#177229) 2025-10-19 engine-flutter-autoroll@skia.org Roll Skia from b864c56efb66 to 899155871d29 (1 revision) (flutter/flutter#177227) 2025-10-19 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from M8WT2GMY46e_0fFho... to tKrvmvTOQITL81oOC... (flutter/flutter#177223) 2025-10-19 engine-flutter-autoroll@skia.org Roll Skia from 0992b560454f to b864c56efb66 (1 revision) (flutter/flutter#177222) 2025-10-18 matt.boetger@gmail.com Fix HEIF decoding (flutter/flutter#176860) 2025-10-18 engine-flutter-autoroll@skia.org Roll Skia from 74df18176924 to 0992b560454f (1 revision) (flutter/flutter#177217) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC louisehsu@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…76176) This is my attempt to handle flutter#6537 for the ListTile widget.
This is my attempt to handle #6537 for the ListTile widget.