jonataslaw / get_storage

A fast, extra light and synchronous key-value storage to Get framework
MIT License
369 stars 83 forks source link

Why is removeListen commented out? #87

Open greatcr7 opened 2 years ago

greatcr7 commented 2 years ago

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

JasonSleigh commented 2 years ago

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 commented 2 years ago

addListener return the dispose function

var dispose = addListener(...

dispose.call() or dispose()

ReggieMiller1 commented 2 years ago

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

kaushikcrypticalinfo commented 2 years ago

I'm facing the same issue too.

yasht01 commented 2 years ago

Facing the same issue.

blueeyestw commented 2 years ago

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();
  }