Getting started
This package provides a riverpod code generator for the stateful_service
package, which allows you
to easily create Riverpod providers for your StatefulService
instances.
See the stateful_service
package documentation for more information on how to get started.
Once you have a StatefulService
, you can easily create a Riverpod notifier provider for it using
an annotation:
part 'user_service.g.dart';
part 'user_service.stateful_service.dart';
@riverpodService
class UserService extends StatefulService<User> {
...
}
You can then use the provider as you would any other Riverpod provider:
Widget build(BuildContext context, WidgetRef ref) {
final user = ref.watch(userServiceProvider);
...
}
You can also access the service directly using the included Provider
extension, e.g:
Widget build(BuildContext context, WidgetRef ref) {
final userService = ref.watch(userServiceProvider.service);
...
}