mixin AppointmentAdapter on RemoteAdapter<Appointment> {
Future<Appointment?> fetchNext() async {
return await sendRequest(
baseUrl.asUri / type / 'next',
onSuccess: (data) => deserialize(data).model,
);
}
}
Using sendRequest
we have both fine-grained control over our request while leveraging existing adapter features such as type
, baseUrl
, deserialize
and any other customizations.
Adapters are applied on RemoteAdapter
but Flutter Data will automatically create shortcuts to call these custom methods.
final nextAppointment = await appointmentRepository.appointmentAdapter.fetchNext();