Last active
March 9, 2019 14:07
-
-
Save yakubenko/e40c25ec023e0e59048211fa1bbfbfc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import 'dart:async'; | |
| class CounterBloc { | |
| int _counter = 0; | |
| final _stateController = StreamController<int>(); | |
| Stream<int> get counterStream => _stateController.stream; | |
| void modifyCounter(String direction) { | |
| if (direction == 'up') { | |
| _counter++; | |
| } else { | |
| _counter--; | |
| } | |
| _stateController.sink.add(_counter); | |
| } | |
| void dispose() { | |
| _stateController.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment