bloc_simple 1.0.2
bloc_simple: ^1.0.2 copied to clipboard
A package that makes life more easier
BlocSimple
A simplified approach to using the BLoC pattern in Flutter. Reduce boilerplate, improve readability, and streamline state management with powerful utilities.
โจ Features ๐ Simplified State Management Pre-defined SimpleState
๐ Minimal Boilerplate Just extend SimpleCubit or SimpleBloc, no extra setup required.
๐ Repository Integration Easily connect BLoCs and Cubits to external data sources with RepositoryConnector.
โก Async Execution Automatically handle async loading, success, and error states using executeAsync.
๐งช Testing Support Built-in testing utilities for unit and widget tests.
๐ Installation Add this to your pubspec.yaml:
yaml Copy Edit dependencies: bloc_simple: ^1.0.2 ๐ฆ Usage ๐งฎ Counter Cubit Example dart Copy Edit class CounterCubit extends SimpleCubit
void increment() => setSuccess((state.data ?? 0) + 1); void decrement() => setSuccess((state.data ?? 0) - 1); } ๐ผ๏ธ In UI dart Copy Edit BlocBuilder<CounterCubit, SimpleState
Future
@override void registerEventHandlers() { on
SimpleState.initial() โ Initial idle state
SimpleState.loading() โ While loading
SimpleState.success(data) โ On success
SimpleState.error(message) โ On error
๐งช Testing Utilities Easily test your SimpleCubit or SimpleBloc with:
dart Copy Edit testSimpleCubit
๐ License MIT ยฉ Dwaipayan Biswas
Built with โค๏ธ by Dwaipayan Biswas