Skip to content

Instantly share code, notes, and snippets.

@becek2n
Created May 8, 2020 16:17
Show Gist options
  • Save becek2n/5cec41adfb63be376f81b08cd96dd100 to your computer and use it in GitHub Desktop.
Save becek2n/5cec41adfb63be376f81b08cd96dd100 to your computer and use it in GitHub Desktop.
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