bloc_riverpod 0.0.2 copy "bloc_riverpod: ^0.0.2" to clipboard
bloc_riverpod: ^0.0.2 copied to clipboard

discontinuedreplaced by: riverbloc

BlocProvider implementation with riverpod as alternative to provider.

example/main.dart

import 'package:riverpod/riverpod.dart';
import 'package:bloc_riverpod/bloc_riverpod.dart';

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

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

final counterProvider = BlocProvider.autoDispose
    // ignore: avoid_types_on_closure_parameters
    .family((ref, int initialCounter) => CounterCubit(initialCounter));

void main() {
  final container = ProviderContainer();
  // Access the bloc directly
  final counterCubit = container.read(counterProvider(0));

  counterCubit.increment();
  counterCubit.increment();

  // Prints '2'
  // ignore: avoid_print
  print(counterCubit.state);

  container.dispose();
}
3
likes
130
pub points
0%
popularity

Publisher

unverified uploader

BlocProvider implementation with riverpod as alternative to provider.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

bloc, meta, riverpod

More

Packages that depend on bloc_riverpod