Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created April 5, 2021 15:40
Show Gist options
  • Save fredgrott/ab4b0f704ebfbf469f277a253be3aefc to your computer and use it in GitHub Desktop.
Save fredgrott/ab4b0f704ebfbf469f277a253be3aefc to your computer and use it in GitHub Desktop.
counter statenotifier
class CounterNotifier extends StateNotifier<CounterModel> with UtilityLogger {
CounterNotifier() : super(_initialValue);
static const _initialValue = CounterModel(0);
void increment() {
state = CounterModel(state.count + 1);
// log our state change
//myAppLog("count increased by 1");
logger.info(penInfo("count increased by 1"));
}
}
class CounterModel {
const CounterModel(this.count);
final int count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment