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

Why is removeListen commented out? #87

Open
greatcr7 opened this issue Dec 23, 2021 · 6 comments
Open

Why is removeListen commented out? #87

greatcr7 opened this issue Dec 23, 2021 · 6 comments

Comments

@greatcr7
Copy link

Trying to remove the listener under dispose but can't....

@JasonSleigh
Copy link

Have you managed to find a way to do this? I have used a box.listenKey((value) {}); .. but when I try to dispose as per documentation eg: box.removeListen(listen); I get a syntax error telling me that get_storage does not have a function called removeListen ?? please help as now I have set state braking when trying to dispose the widget.

@jonataslaw
Copy link
Owner

addListener return the dispose function

var dispose = addListener(...

dispose.call()
or
dispose()

@ReggieMiller1
Copy link

im facing the same issue too...i cant remove the listeners on dispose.

@kaushikcrypticalinfo
Copy link

I'm facing the same issue too.

@yasht01
Copy link

yasht01 commented Jun 15, 2022

Facing the same issue.

@blueeyestw
Copy link

solution:

  Function? disposeListen;

  @override
  void initState() {
    GetStorage getStorage = GetStorage();
    disposeListen = getStorage.listenKey('my_key', (value) {
      //your code here
    });
    super.initState();
  }

  @override
  void dispose() {
    disposeListen?.call();
    super.dispose();
  }

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

7 participants