Skip to content

Conversation

@ahmedsameha1
Copy link
Contributor

This is my attempt to handle #6537 for the ListTile widget.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Sep 28, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 4716 to 4725
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);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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');
    }
  });

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

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

@dkwingsmt
Copy link
Contributor

There are still leftover comments.

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Oct 19, 2025
Merged via the queue into flutter:master with commit 038f22d Oct 19, 2025
78 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 20, 2025
flutter/flutter@891d7d5...2d34167

2025-10-20 [email protected] Cleanup create_updated_flutter_deps.py a bit (flutter/flutter#177162)
2025-10-20 [email protected] Fixed hot reload/restart crashes after closing browser tab on web-server device (flutter/flutter#177026)
2025-10-20 [email protected] Roll Skia from 0a3ace6fde82 to ed4294faecde (2 revisions) (flutter/flutter#177249)
2025-10-20 [email protected] Add DropdownMenu.decorationBuilder (flutter/flutter#176264)
2025-10-20 [email protected] Roll Skia from 05e2f42f533d to 0a3ace6fde82 (1 revision) (flutter/flutter#177242)
2025-10-20 [email protected] Roll Skia from 89abc5393317 to 05e2f42f533d (1 revision) (flutter/flutter#177238)
2025-10-20 [email protected] [ios][engine] Fix autofill context cleanup and view lifecycle management (flutter/flutter#173598)
2025-10-20 [email protected] Fix Image.network not using cache when headers are specified (flutter/flutter#176831)
2025-10-19 [email protected] Roll Dart SDK from a66f334fee2a to 2cd2106f2cef (4 revisions) (flutter/flutter#177190)
2025-10-19 [email protected] Roll Skia from 2d424175a481 to 89abc5393317 (1 revision) (flutter/flutter#177235)
2025-10-19 [email protected] Make sure that a ListTile doesn't crash in 0x0 environment (flutter/flutter#176176)
2025-10-19 [email protected] Make sure that a DropdownButton doesn't crash in 0x0 environment (flutter/flutter#174880)
2025-10-19 [email protected] Roll Skia from 899155871d29 to 2d424175a481 (1 revision) (flutter/flutter#177229)
2025-10-19 [email protected] Roll Skia from b864c56efb66 to 899155871d29 (1 revision) (flutter/flutter#177227)
2025-10-19 [email protected] Roll Fuchsia Linux SDK from M8WT2GMY46e_0fFho... to tKrvmvTOQITL81oOC... (flutter/flutter#177223)
2025-10-19 [email protected] Roll Skia from 0992b560454f to b864c56efb66 (1 revision) (flutter/flutter#177222)
2025-10-18 [email protected] Fix HEIF decoding (flutter/flutter#176860)
2025-10-18 [email protected] 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 [email protected],[email protected] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants