// Bloc
import 'package:bloc/bloc.dart';

import 'toggle_event.dart';
import 'toggle_state.dart';

class ToggleBloc extends Bloc<ToggleEvent, ToggleState> {
  ToggleBloc() : super(ToggleInitial()) {
    on<ToggleSwitch>(_onToggleSwitch);
  }

  void _onToggleSwitch(ToggleSwitch event, Emitter<ToggleState> emit) {
    if (state is ToggleOn) {
      emit(ToggleOff());
    } else {
      emit(ToggleOn());
    }
  }
}
