Created
May 12, 2019 22:30
-
-
Save jacobaraujo7/b2b8e26fa1e045b9f2693302ae85da53 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'; | |
import 'package:bloc_pattern/bloc_pattern.dart'; | |
class ValueBloc extends BlocBase { | |
StreamController<double> _valueController = StreamController<double>(); | |
double value = 0.0; | |
//outputs | |
Stream<double> get valueOut => _valueController.stream; | |
Stream<String> get valueStringOut => | |
_valueController.stream.map((v) => "Valor: ${v.toStringAsExponential(1)}"); | |
onChangeValue(double v) { | |
value = v; | |
_valueController.add(value); | |
} | |
//será chamado no fim da aplicação automaticamente | |
@override | |
void dispose() { | |
_valueController.close(); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment