Created
June 7, 2025 03:50
-
-
Save rubywai/93b766c83987749f80a1286d2f6bb554 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 'package:flutter_bloc/flutter_bloc.dart'; | |
| // Define the events | |
| abstract class CounterEvent {} | |
| class CounterIncrement extends CounterEvent {} | |
| class CounterDecrement extends CounterEvent {} | |
| class CounterReset extends CounterEvent {} | |
| // Define the Bloc | |
| class CounterBloc extends Bloc<CounterEvent, int> { | |
| CounterBloc() : super(0) { | |
| on<CounterIncrement>((event, emit) => emit(state + 1)); | |
| on<CounterDecrement>((event, emit) => emit(state - 1)); | |
| on<CounterReset>((event, emit) => emit(0)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment