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

Don't dispose my ScrollController for me #3

Closed
lynn opened this issue Apr 2, 2020 · 2 comments
Closed

Don't dispose my ScrollController for me #3

lynn opened this issue Apr 2, 2020 · 2 comments
Assignees

Comments

@lynn
Copy link

lynn commented Apr 2, 2020

This plugin calls .dispose() on the ScrollController argument it receives.

This means the obvious usage pattern is now wrong:

class _MyWidgetState extends State<MyWidget> {
  ScrollController _myController;

  @override
  void initState() {
    super.initState();
    _myController = ScrollController();
  }

  @override
  void dispose() {
    // Wrong, because this plugin wants me *not* to dispose my own controller!
    _myController.dispose();
    super.dispose();
  }

  @override
  Widget build() {
    return FadingEdgeScrollView.fromScrollView(child: ... _myController ...);
  }
}

This is surprising: If I'm supposed to create the controller and pass it in, it should also be my job to dispose it. This is the way it works everywhere else in Flutter.

So, I think you should not dispose the controller and let the user control its lifetime instead. This user ran into the same problem and would probably agree.

Thank you!

@knaeckeKami
Copy link

Ran into the same issue, please don't dispose the controller or at add a flag for that.

@mponkin mponkin self-assigned this May 20, 2020
@mponkin
Copy link
Owner

mponkin commented May 20, 2020

Thanks for reporting this problem.
I've fixed it in version 1.1.1

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

No branches or pull requests

3 participants