Skip to content

Don't dispose my ScrollController #40

Description

@Guillergood

The plugin executes the .dispose() method on the ScrollController it is provided with.

This renders the expected usage pattern incorrect:

class ScrollSnapListState extends State<ScrollSnapList> {
  ...

  @override
  void dispose() {
    // This approach is now incorrect
    widget.listController.dispose();
    super.dispose();
  }

  ...
}

This outcome is: ScrollController has been disposed and you are trying to use it.

If I am responsible for creating the controller and providing it, I should logically be the one to dispose of it as well. This is the standard practice in Flutter.

Therefore, I suggest that the controller should not be disposed of by the plugin, allowing the user to manage its lifecycle. The issue encountered in mponkin/fading_edge_scrollview#3 seems to support this viewpoint.

Thank you!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions