An implementation of BlocProvider based on #riverpod providers. The goal of this package is to make easy the migration from flutter_bloc to flutter_riverpod.

If you are interested in hooks with bloc, see also flutter_hooks_bloc


It's similar to StateNotiferProvider but with bloc instead of StateNofier.

class CounterCubit extends Cubit<int> {
  CounterCubit(int state) : super(state);

  void increment() => emit(state + 1);

final counterProvider = BlocProvider<CounterCubit, int>(
  (ref) => CounterCubit(0),

class MyHomePage extends ConsumerWidget {
  const MyHomePage({Key? key, this.title}) : super(key: key);

  final String title;

  Widget build(BuildContext context, WidgetRef ref) {
    // Rebuilds the widget if the cubit/bloc changes.
    // But does not rebuild if the state changes with the same cubit/bloc
    final counterCubit =;
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      body: Center(
        child: Column(
          children: <Widget>[
              'initial counterCubit.state: ${counterCubit.state}',
            Consumer(builder: (context, watch, __) {
              // Rebuilds in every emitted state
              final _counter =;
              return Text(
                style: Theme.of(context).textTheme.headline4,
      floatingActionButton: FloatingActionButton(
        onPressed: () =>,
        tooltip: 'Increment',
        child: Icon(Icons.add),


Riverbloc exposes providers for Bloc and Cubit instances bases in riverpod package instead of provider package.