Skip to content

Conversation

@ahmedsameha1
Copy link
Contributor

This is my attempt to handle #6537 for the ReorderableListView 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 Oct 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 for an issue where ReorderableListView crashes in a zero-sized environment. The added test verifies that the widget can be built with zero size, but it doesn't cover the drag interaction that was reported to cause the crash. I've suggested an improved test that simulates a drag while the widget's size is animated to zero, which more accurately reflects the problematic scenario.

Comment on lines +2428 to +2445
testWidgets('ReorderableListView does not crash at zero area', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: SizedBox.shrink(
child: ReorderableListView(
children: const <Widget>[
Text(key: Key('x'), 'X'),
Text(key: Key('y'), 'Y'),
],
onReorder: (_, _) {},
),
),
),
),
);
expect(tester.getSize(find.byType(ReorderableListView)), 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 only verifies that ReorderableListView can be built with a zero size. It doesn't test the drag interaction described in issue #6537 that causes the crash. To properly cover the issue, the test should simulate a drag on the ReorderableListView while its size is being reduced to zero.

  testWidgets('ReorderableListView does not crash at zero area during drag', (WidgetTester tester) async {
    // Start with a non-zero size to allow starting a drag.
    await tester.pumpWidget(
      MaterialApp(
        home: Center(
          child: SizedBox(
            width: 200,
            height: 200,
            child: ReorderableListView(
              children: const <Widget>[
                SizedBox(key: Key('x'), height: 50, child: Text('X')),
                SizedBox(key: Key('y'), height: 50, child: Text('Y')),
              ],
              onReorder: (_, __) {},
            ),
          ),
        ),
      ),
    );

    final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byKey(const Key('x'))));
    await tester.pump(kLongPressTimeout); // Start the drag.

    // Animate size to zero while dragging.
    await tester.pumpWidget(
      MaterialApp(
        home: Center(
          child: SizedBox.shrink(
            child: ReorderableListView(
              children: const <Widget>[
                SizedBox(key: Key('x'), height: 50, child: Text('X')),
                SizedBox(key: Key('y'), height: 50, child: Text('Y')),
              ],
              onReorder: (_, __) {},
            ),
          ),
        ),
      ),
    );

    // Move the gesture and settle. This should not crash.
    await gesture.moveBy(const Offset(0, 10));
    await tester.pumpAndSettle();
    await gesture.up();
    expect(tester.takeException(), isNull);
  });

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 Author

@ahmedsameha1 ahmedsameha1 Oct 31, 2025

Choose a reason for hiding this comment

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

Applying this gives me:
Drag target size is larger than scrollable size, which may cause bouncing
'package:flutter/src/widgets/scrollable_helpers.dart':
Failed assertion: line 241 pos 7: '(globalRect.size.width + precisionErrorTolerance) >=
transformedDragTarget.size.width &&
(globalRect.size.height + precisionErrorTolerance) >= transformedDragTarget.size.height'

@victorsanni victorsanni requested a review from dkwingsmt October 30, 2025 22:15
@dkwingsmt
Copy link
Contributor

I don't think it's possible to verify the dragging behavior at zero size. We might be able to do it with a small size (such as 1x1, which is effectively almost equivalent. Although, I'm willing to delay it to another day until it's actually found broken due to its potential difficulty, but feel free to give it a try if you'd like to.

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.

LGTM

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 19, 2025

autosubmit label was removed for flutter/flutter/177646, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2025
@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Nov 19, 2025
Merged via the queue into flutter:master with commit 452314c Nov 19, 2025
71 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 19, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 19, 2025
flutter/flutter@cb7b7df...de4be4f

2025-11-19 [email protected] Roll Skia from 2054d87c6a85 to b5dc8c3494ac (1 revision) (flutter/flutter#178793)
2025-11-19 [email protected] Roll Skia from a30b02d57637 to 2054d87c6a85 (2 revisions) (flutter/flutter#178787)
2025-11-19 [email protected] Roll Skia from 547e3e5441b4 to a30b02d57637 (3 revisions) (flutter/flutter#178782)
2025-11-19 [email protected] Fix train hopping animation status listeners (flutter/flutter#178372)
2025-11-19 [email protected] Make sure that a ReorderableListView doesn't crash in 0x0 environment (flutter/flutter#177646)
2025-11-19 [email protected] Roll Skia from 9ce01a452f63 to 547e3e5441b4 (1 revision) (flutter/flutter#178775)
2025-11-19 [email protected] Roll Dart SDK from 1ed6b56bb323 to f7e9bd245fd9 (1 revision) (flutter/flutter#178774)
2025-11-19 [email protected] Roll Skia from f3ddc700abc7 to 9ce01a452f63 (8 revisions) (flutter/flutter#178769)
2025-11-19 [email protected] Make sure that a TabPageSelector doesn't crash in 0x0 environment (flutter/flutter#178156)
2025-11-19 [email protected] Small cleanup in `DeferredComponentManager.java‎` (flutter/flutter#178585)
2025-11-19 [email protected] Roll Dart SDK from a33149cb6643 to 1ed6b56bb323 (1 revision) (flutter/flutter#178763)
2025-11-18 [email protected] Roll Skia from 8557300f84c2 to f3ddc700abc7 (5 revisions) (flutter/flutter#178751)
2025-11-18 [email protected] Remove unnecessary `String.valueOf` in `TextInputChannel.java` (flutter/flutter#178592)
2025-11-18 [email protected] [tool] Further cleanup of proxy logic (flutter/flutter#178683)
2025-11-18 [email protected] Restore OpenGL state modified by fl_compositor_opengl_present_layers (flutter/flutter#178697)
2025-11-18 [email protected] Replace `equals("")` with `isEmpty` in `SpellCheckPlugin.java‎` (flutter/flutter#178596)
2025-11-18 [email protected] Roll Dart SDK from 312845b06afc to a33149cb6643 (2 revisions) (flutter/flutter#178738)
2025-11-18 [email protected] Roll Skia from ca906091e199 to 8557300f84c2 (2 revisions) (flutter/flutter#178739)
2025-11-18 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add framework-side hitTestBehavior support for Semantics widget and apply to ModalRoute (#177570)" (flutter/flutter#178744)
2025-11-18 [email protected] Roll Packages from ce44ebb to 34746bb (6 revisions) (flutter/flutter#178734)

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
okorohelijah pushed a commit to okorohelijah/flutter that referenced this pull request Nov 21, 2025
…flutter#177646)

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

Co-authored-by: Victor Sanni <[email protected]>
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
…flutter#177646)

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

Co-authored-by: Victor Sanni <[email protected]>
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…flutter#177646)

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

Co-authored-by: Victor Sanni <[email protected]>
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…flutter#177646)

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

Co-authored-by: Victor Sanni <[email protected]>
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