Skip to main content

sinew_riverpod 1.0.0 copy "sinew_riverpod: ^1.0.0" to clipboard
sinew_riverpod: ^1.0.0 copied to clipboard

Riverpod notifier mixins, hooks and AsyncValue conversions for Sinew's presentation pattern.

example/README.md

sinew_riverpod example #

A complete app that uses this package, with every platform runner, is the repository's example: a paged list of orders through Sinew's pager, its Riverpod mixins and Camouflage's CamoPagedList.

Usage #

A list page in a notifier (from the example app):

class OrderList extends Notifier<OrderListState>
    with
        StateEffectNotifier<OrderListState, Never>,
        EventActionNotifier<OrderListState, OrderListEvent, LoadOrders, Never> {
  late final Pager<Order> _pager = Pager.offset(
    (page, _) => ref.read(orderBackendProvider).orders(page),
    itemKey: (order) => order.id,
  );

  @override
  OrderListState build() => const OrderListState();

  @override
  LoadOrders? mapEventToAction(OrderListEvent event) => switch (event) {
    OrderListOpened() => const LoadOrders(LoadType.initial),
    OrderListEndReached() =>
      state.orders.canLoadMore ? const LoadOrders(LoadType.more) : null,
    OrderListRetryTapped() => LoadOrders(state.orders.retryType),
    OrderListRefreshed() => const LoadOrders(LoadType.refresh),
  };

  @override
  Future<void> onAction(LoadOrders action) => _pager.load(
    action.type,
    state.orders,
    update: (next) => setState((_) => OrderListState(orders: next)),
  );
}

The page calls ref.read(orderListProvider.notifier).onEvent(...).

0
likes
160
points
183
downloads

Documentation

Documentation
API reference

Publisher

verified publishersrctool.com

Weekly Downloads

Riverpod notifier mixins, hooks and AsyncValue conversions for Sinew's presentation pattern.

Repository (GitHub)
View/report issues
Contributing

Topics

#riverpod #state-management #architecture

License

Apache-2.0 (license)

Dependencies

flutter, flutter_hooks, meta, riverpod, sinew_exception, sinew_models, sinew_presentation

More

Packages that depend on sinew_riverpod