Created
May 8, 2020 16:17
-
-
Save becek2n/5cec41adfb63be376f81b08cd96dd100 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 StepperBloc extends Bloc<StepperEvent, StepperState> { | |
void onContinue() { | |
dispatch(ContinueEvent()); | |
} | |
void onBack() { | |
dispatch(BackEvent()); | |
} | |
void onSaveRate(double rate, double volume) { | |
dispatch(SaveRateEvent(rate: rate, volume: volume)); | |
} | |
@override | |
StepperState get initialState => StepperState.initial(); | |
@override | |
Stream<StepperState> mapEventToState(StepperState state, StepperEvent event) async* { | |
final _currentState = currentState; | |
if (event is ContinueEvent) { | |
yield StepperState(currentStep: _currentState.currentStep + 1, rate: _currentState.rate, volume: _currentState.volume); | |
} else if (event is BackEvent) { | |
yield StepperState(currentStep: _currentState.currentStep - 1, rate: _currentState.rate, volume: _currentState.volume); | |
} else if (event is SaveRateEvent) { | |
yield StepperState(currentStep: _currentState.currentStep, rate: event.rate, volume: event.volume); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment