Skip to content

Conversation

@ahmedsameha1
Copy link
Contributor

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Dec 31, 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 test to ensure LongPressDraggable doesn't crash in a zero-size environment. The test correctly sets up the scenario with a zero-sized widget. However, it misses simulating the long press gesture, which is the actual trigger for the crash described in the associated issue. I've added suggestions to complete the test by adding the long press action and also to improve code style by using const constructors.

),
),
);
expect(tester.getSize(find.byType(LongPressDraggable<bool>)), 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.

high

This test is intended to verify that LongPressDraggable doesn't crash in a zero-sized environment, as per the issue description. However, it only checks that the widget can be created with a zero size. It doesn't simulate a long press, which is the action that would trigger the crash.

To properly test the fix, you should simulate a long press gesture on the widget.

    expect(tester.getSize(find.byType(LongPressDraggable<bool>)), Size.zero);

    // This should not crash.
    await tester.longPress(find.byType(LongPressDraggable<bool>));
    await tester.pump();

Comment on lines +130 to +131
feedback: Text('Y'),
child: Text('X'),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better performance and to follow Dart best practices, it's recommended to use const for constructors of widgets that do not change, like Text with a constant string.

Suggested change
feedback: Text('Y'),
child: Text('X'),
feedback: const Text('Y'),
child: const Text('X'),

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

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant