Data Layer medium complexity mobile
1
Dependencies
1
Dependents
1
Entities
0
Integrations

Description

Riverpod providers that expose role-aware contact and peer mentor streams to the UI layer. Manages loading, error, and data states using AsyncValue and automatically re-fetches when the authenticated user's role or organization context changes.

Feature: Contact List Management

contact-list-riverpod-provider

Summaries

The Contact List Riverpod Provider is the real-time intelligence layer that ensures the contact list always reflects the current user's role, organization, and search state without requiring manual refreshes. For end users, this translates to a contact list that stays accurate as organizational context changes — preventing staff from working with stale data that could lead to incorrect outreach or support decisions. For the business, automated state management reduces support tickets related to 'wrong contacts showing' and builds user trust in the platform's reliability. Its reactive architecture also means new role types or organizational structures can be accommodated with minimal UI-layer changes, reducing future development cost.

Contact List Riverpod Provider is a medium-complexity state management layer that depends on contact-repository being complete and stable. Its reactive nature — auto-refreshing when auth context or organization changes — requires careful coordination with the authentication feature team to ensure the session and organization context providers are available and correctly structured before integration. The AsyncValue pattern (loading, error, data states) introduces UI states that all consuming widgets must handle, meaning UI developers need clear contracts for all three states before building screens against this provider. Plan for integration testing that simulates auth context switches and org changes.

Because it is not marked as shared, its scope is bounded to the contact list feature, limiting blast radius of changes.

ContactListRiverpodProvider exposes a set of Riverpod providers that bridge the service layer to the Flutter widget tree. `contactListProvider` and `peerMentorListProvider` are `AsyncNotifierProvider` or `FutureProvider` instances returning `AsyncValue>` and `AsyncValue>` respectively, delegating to `ContactListService`. `contactSearchQueryProvider` is a `StateProvider` whose changes trigger `filteredContactListProvider` and `filteredPeerMentorListProvider` to recompute via `.watch()`. Auth and organization context changes should invalidate the base list providers using `ref.invalidate()` or by watching an auth state provider.

`selectedContactViewProvider` is a `StateProvider` for detail view selection. Providers should use `ref.onDispose()` to cancel any pending async operations. Ensure all providers are registered in the appropriate `ProviderScope` and that family variants are used if multi-org support requires concurrent provider instances.

Responsibilities

  • Provide role-aware AsyncValue<List<Contact>> to UI widgets
  • Provide role-aware AsyncValue<List<PeerMentor>> to UI widgets
  • Expose search query state and trigger filtered fetches on query change
  • Invalidate and refresh on auth context or organization change

Interfaces

contactListProvider
peerMentorListProvider
contactSearchQueryProvider
filteredContactListProvider
filteredPeerMentorListProvider
selectedContactViewProvider

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/contacts/providers 4 endpoints
GET /api/v1/contacts/providers/contact-list Resolve the full contact list state (mirrors contactListProvider)
GET /api/v1/contacts/providers/peer-mentor-list Resolve the peer mentor list state (mirrors peerMentorListProvider)
GET /api/v1/contacts/providers/filtered Resolve the filtered contact list state (mirrors filteredContactListProvider)
PUT /api/v1/contacts/providers/search-query Update the active search query state (mirrors contactSearchQueryProvider)