findOne method

Future<T?> findOne(
  1. dynamic id, {
  2. bool? remote,
  3. Map<String, dynamic>? params,
  4. Map<String, String>? headers,
  5. OnDataError<T>? onError,
})

Returns model of type T by id.

If _RemoteAdapter.shouldLoadRemoteOne (function of remote) is true, it will initiate an HTTP call. Otherwise returns model of type T and id in local storage.

Arguments params and headers will be merged with _RemoteAdapter.defaultParams and _RemoteAdapter.defaultHeaders, respectively.

See also: _RemoteAdapter.urlForFindOne, _RemoteAdapter.methodForFindOne.

Implementation

Future<T?> findOne(
  final dynamic id, {
  bool? remote,
  Map<String, dynamic>? params,
  Map<String, String>? headers,
  OnDataError<T>? onError,
}) {
  return remoteAdapter.findOne(
    id,
    remote: remote,
    params: params,
    headers: headers,
    onError: onError,
  );
}