riverpod_stateful_service 1.0.0+2 copy "riverpod_stateful_service: ^1.0.0+2" to clipboard
riverpod_stateful_service: ^1.0.0+2 copied to clipboard

This package provides a lightweight stateful_service wrapper for Riverpod. See the stateful_service package for more information.

pub package popularity likes pub points building

Lightweight stateful_service wrapper for riverpod.

Getting started #

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:

class UserService extends StatefulService<User> {
  ...
}

final StatefulServiceNotifierProvider<UserService, User> userProvider = StatefulServiceNotifierProvider((ref) {
  return StatefulServiceNotifier(UserService(initialState: const User(name: 'John Doe')));
});

You can then use the provider as you would any other Riverpod provider:

Widget build(BuildContext context, WidgetRef ref) {
  final user = ref.watch(userProvider);
  ...
}

You can also access the service directly using the included Provider extension, e.g:

Widget build(BuildContext context, WidgetRef ref) {
  final userService = ref.watch(userProvider.service);
  ...
}
2
likes
0
points
556
downloads

Publisher

verified publisherwolverinebeach.net

Weekly Downloads

This package provides a lightweight stateful_service wrapper for Riverpod. See the stateful_service package for more information.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

riverpod, stateful_service

More

Packages that depend on riverpod_stateful_service