Skip to content
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

fix: arbitrarily disposes of the passed controller #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asci-00
Copy link

@asci-00 asci-00 commented May 28, 2024

Thank you for providing an excellent package.
An unexpected behavior occurred during use, and I am writing a PR because I would like to contribute to a better package.

Checklist

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Is there an existing issue for this PR?
    • link issue here (use keywords like fix, close, resolve etc. if necessary)
  • Have the files been linted and formatted?
  • Have the docs been updated to match the changes in the PR?
  • Have the tests been updated to match the changes in the PR?
  • Attached videos/screenshots demonstrating the fix/feature.
  • Have you run the tests locally to confirm they pass?

Changes

Current:
For DraggableScrollableController, it is implemented to dispose the controller unconditionally when disposing without distinguishing between the controller created in FlexibleBottomSheet and the controller passed as a parameter.

Change:
In the case of DraggableScrollableController passed as a parameter from the outside, change it not to be disposed so that it can be managed by itself from the outside.

What is the current behavior, and the steps to reproduce the issue?

In general, in the case of a controller passed to a widget or function, create/dispose is carried out by the entity that passed it. (ex. TextEditingController passed to TextField, ScrollController passed to ScrollView.)
However, FlexibleBottomSheet internally disposes the DraggableScrollableController passed as a parameter from the outside.

This causes confusion and an exception occurs in the code below.

final controller = DraggableScrollableController();

await showFlexibleBottomSheet(
context: context,
...
draggableScrollableController: controller,
);

controller.dispose(); 

// exception: The "dispose()" method on ~ was called during the call to

What is the expected behavior?

No exception occurs.

How does this PR fix the problem?

DraggableScrollableController passed as a parameter from outside is not disposed in FlexibleBottomSheet.
With this change, the controller can manage itself externally,
and no exception is thrown when closing the bottomsheet in the code above.

fix: arbitrarily disposes of the passed controller
Copy link

@sijan-vt sijan-vt left a comment

Choose a reason for hiding this comment

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

I have personally tested it and it is working. I was facing similar issue and using this change fixed my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants