Created
November 26, 2020 17:28
-
-
Save isacjunior/652ac2044365c34d145c17fda8df7838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter { | |
Counter({this.count}); | |
int count; | |
void increment() { | |
count++; | |
} | |
void decrement() { | |
count--; | |
} | |
} | |
enum CounterTypes { | |
increment, | |
decrement, | |
} | |
class CounterStore with ChangeNotifier { | |
Counter _counter = Counter(count: 0); | |
int get count => _counter.count; | |
void dispatch(CounterTypes type) { | |
final action = { | |
CounterTypes.increment: _counter.increment, | |
CounterTypes.decrement: _counter.decrement, | |
}[type]; | |
action(); | |
notifyListeners(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment