20 lines
418 B
Dart
20 lines
418 B
Dart
// 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());
|
|
}
|
|
}
|
|
}
|