kranfix / riverbloc

`flutter_bloc` implemented with `riverpod` instead of `provider`.
83 stars 16 forks source link

Support non-hooks version of riverpod #12

Closed chimon2000 closed 4 years ago

chimon2000 commented 4 years ago

I would like to request support for the non-hooks version of riverpod, as detailed on the landing page. Here is a rough draft of how I'd expect it to look:

final counterProvider = BlocProvider((ref) {
  return Counter();
});

class Counter extends Cubit<int> {
  Counter(): super(0);

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

class Home extends ConsumerWidget {
  @override
  Widget build(BuildContext context, ScopedReader watch) {
    final count = watch(countProvider.state);
    return Text('$count');
  }
}

If this is currently supported, I didn't see any mention in the existing documentation.

kranfix commented 4 years ago

Hello. I am working exactly on it. In few hours I will be publishing the draft of the API and what problems I am trying to revolve resolve.

I started with flutter_hooks_bloc first because I needed to have a laboratory to experiment with bloc and hooks to have it as an input for the riverbloc api.

chimon2000 commented 4 years ago

Awesome, looking forward to playing with the API!

kranfix commented 4 years ago

@chimon2000 sorry for delay. Rivebloc is alive! https://pub.dev/packages/riverbloc

chimon2000 commented 4 years ago

@kranfix finally got around to playing with this and it works like a charm.

A minor nit:

Should add docs for usage with Consumer/ConsumerWidget and read vs. watch. I know that this is specific to riverpod, but it would be useful, especially with links back to riverpod explaining how those things work.

kranfix commented 4 years ago

The riverbloc pacakage is published and the docs will be added soon and it was moved to #22.