no_bloc 0.13.4 copy "no_bloc: ^0.13.4" to clipboard
no_bloc: ^0.13.4 copied to clipboard

Make bloc easy again! A simple and low boilerplate implementation of the bloc state management pattern. Includes extras to work with blocs like testing, monitoring and persistence.

example/main.dart

import 'package:no_bloc/no_bloc.dart';

class BroadcastPrinter extends BlocMonitor {
  @override
  void onBroadcast(String blocName, state, {String? event}) {
    print('[$blocName] broadcast: $state ($event)');
  }
}

class CounterBloc extends Bloc<int> {
  CounterBloc() : super(initialState: 0, monitor: BroadcastPrinter());

  // event names are optional and only used for debugging purpose
  void increment() => setState(state + 1, event: 'increment');
  void decrement() => setState(state - 1, event: 'decrement');
}

void main() {
  final bloc = CounterBloc();

  bloc.stream.listen((s) => print(s));

  bloc.increment();
  bloc.decrement();
}
6
likes
120
pub points
5%
popularity

Publisher

verified publishermuha.dev

Make bloc easy again! A simple and low boilerplate implementation of the bloc state management pattern. Includes extras to work with blocs like testing, monitoring and persistence.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

hive, meta, path, pedantic, quick_log, rxdart, test

More

Packages that depend on no_bloc