arch-atlas

Customer Order Controller

controllers/order_controller.dart · AsyncNotifier<List<Order>>

domain

Overview

AsyncNotifier that loads the customer's orders on build and exposes refreshOrders. State is AsyncValue<List<Order>> so the screen can render loading / error / data without manual flags.

User Flow

  1. build() returns OrderService.getOrders() — Riverpod caches the result.
  2. refreshOrders sets state to AsyncValue.loading, then re-runs getOrders inside AsyncValue.guard for typed error capture.
  3. OrdersScreen ref.watches the provider and re-renders on every state transition.

Cases & Edge Cases

  • Network failure on build surfaces as AsyncValue.error; the screen shows a retry button that calls refreshOrders.
  • List is reversed by OrderService (newest first) — the controller does not re-sort.
  • No pagination yet — getOrders returns whatever the backend default limit is (50).

Code References

  • lib/src/features/shared/orders/controllers/order_controller.dart:7 // OrderController
  • lib/src/features/shared/orders/controllers/order_controller.dart:23 // orderControllerProvider

API Calls

Empty — fill this in later. Open the manifest and add content here.

Notes

Use ref.invalidate(orderControllerProvider) from completing checkout to force a refresh — the controller is not auto-invalidated.