Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

statenotifier hook

build workflow
codecov

this package provides a usestatenotifier hook similar to usevaluelistenable. there is also
usecreatestatenotifier hook which creates a statenotifier and automatically dispose it.

usage

// 1. create your state notifier as usual.
class counternotifier extends statenotifier<int> {
  counternotifier() : super(0);

  void increment() => state++;
  void decrement() => state--;
}

// 2. extend hook widget
class readmeexample extends hookwidget {
  const readmeexample({key? key}) : super(key: key);

  @override
  widget build(buildcontext context) {
    // 3. create your notifier (usecreatestatenotifier will dispose it)
    final notifier = usecreatestatenotifier(() => counternotifier());
    // 4. listen to your state
    final state = usestatenotifier(notifier);
    
    //......
  }
}

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.