getLatest method Null safety

Future<T?> getLatest(
  1. {Query? query,
  2. bool alwaysHydrate = false,
  3. bool hydrateUnexisting = true,
  4. bool requireRemote = false,
  5. bool seedOnly = false}
)

Get the latest result from the repository

Implementation

Future<T?> getLatest({
  Query? query,
  bool alwaysHydrate = false,
  bool hydrateUnexisting = true,
  bool requireRemote = false,
  bool seedOnly = false,
}) async {
  try {
    final items = await get(
      query: query,
      alwaysHydrate: alwaysHydrate || !hydrated,
      hydrateUnexisting: hydrateUnexisting,
      requireRemote: requireRemote,
      seedOnly: seedOnly,
    );
    return items != null && items.isNotEmpty ? items.last : null;
  } on HttpException {
    rethrow;
  }
}