apiProvider top-level property

StateNotifierProvider<ApiNotifier, AsyncValue<ApiResult>> apiProvider
final

Single API notifier. One instance per screen via apiProvider.family or shared globally — your choice.

Usage — call ApiNotifier.send from a screen or button handler:

final result = await ref.read(apiProvider.notifier).send(
  PostRequest<ResolveEmailResponse>(
    endpoint: V1.auth.postResolveEmail,
    version: ApiVersion.v1,
    noAuth: true,
    body: body.toJson(),
    fromJson: ResolveEmailResponse.fromJson,
  ),
);

fromJson always receives the full backend response body. Feature DTOs are responsible for extracting endpoint-specific fields.

Implementation

final apiProvider =
    StateNotifierProvider<ApiNotifier, AsyncValue<ApiResult<dynamic>>>(
        (ref) => ApiNotifier());