Skip to content

Add regression test for Slider inside TableRow#180342

Closed
divyanshyagyik wants to merge 3 commits into
flutter:masterfrom
divyanshyagyik:slider-table-regression-test
Closed

Add regression test for Slider inside TableRow#180342
divyanshyagyik wants to merge 3 commits into
flutter:masterfrom
divyanshyagyik:slider-table-regression-test

Conversation

@divyanshyagyik

Copy link
Copy Markdown

Description

Adds a regression test for a framework assertion that occurs when a Slider
is placed inside a TableRow.

Issue

#180337

Details

Placing a Slider (which uses OverlayPortal) inside a Table triggers a
child.owner == owner assertion. This test reproduces the failure and
guards against future regressions.

@google-cla

google-cla Bot commented Dec 27, 2025

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Dec 27, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 prevent a crash when a Slider is used within a TableRow. The added test is clear and correctly reproduces the issue. I've only found a minor formatting and best practice issue that can be easily fixed.

Comment on lines +922 to +946
testWidgets(
'Table widget - Slider inside TableRow does not crash',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Table(
children: <TableRow>[
TableRow(
children: <Widget>[
Slider(
value: 0.0,
onChanged: null,
),
],
),
],
),
),
),
);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
},
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The formatting of this test block seems to be off. Running dart format should fix it.

Additionally, the widget tree can be made a const expression. This is a good practice for performance as it allows Flutter to skip unnecessary rebuilds for widgets that do not change.

  testWidgets(
    'Table widget - Slider inside TableRow does not crash',
    (WidgetTester tester) async {
      await tester.pumpWidget(
        const MaterialApp(
          home: Scaffold(
            body: Table(
              children: <TableRow>[
                TableRow(
                  children: <Widget>[
                    Slider(
                      value: 0.0,
                      onChanged: null,
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      );
      await tester.pumpAndSettle();
      expect(tester.takeException(), isNull);
    },
  );
References
  1. All Dart code is formatted using dart format. This is enforced by CI. (link)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Formatting fixed using dart format, and widget tree is now const. Thanks!

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Won't this fail until #180337 is fixed?

Also heads up there is an analyzer failure.

@divyanshyagyik

Copy link
Copy Markdown
Author

yes, the test currently reproduces the failure on master and would fail until the underlying issue is fixed.

Happy to mark this as blocked or adjust the test if you’d prefer it to land alongside the fix instead.

The analyzer failure appears unrelated to this change.

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I see. Can you add a skip: true and a TODO comment saying to unskip this when #180337 is fixed? Also, check the analyzer failure.

Comment on lines +933 to +934
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think these two lines are unnecessary.

@justinmc

justinmc commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

Actually I'm going to close this PR before you spend any more time on it. My opinion is that we shouldn't land skipped tests like this because it adds complexity to the test file. Instead, leave a comment on the issue with your test, and when the issue gets fixed, it can be included in that PR.

If anyone strongly agrees with me here let me know and I'll reconsider. Thanks @divyanshyagyik for the work anyway, and if you end up submitting a PR fixing the issue I'd be happy to review that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants