gets<R> method

  1. @override
Future<Response<T>> gets<R>({
  1. bool onlyUpdatedData = false,
  2. Map<String, dynamic>? extra,
  3. R? source(
    1. R parent
    )?,
})
override

Implementation

@override
Future<Response<T>> gets<R>({
  bool onlyUpdatedData = false,
  Map<String, dynamic>? extra,
  R? Function(R parent)? source,
}) async {
  final response = Response<T>();
  try {
    final result = await _source(source).get();
    if (result.docs.isNotEmpty || result.docChanges.isNotEmpty) {
      if (onlyUpdatedData) {
        List<T> list = result.docChanges.map((e) {
          return build(e.doc.data());
        }).toList();
        return response.copy(result: list);
      } else {
        List<T> list = result.docs.map((e) {
          return build(e.data());
        }).toList();
        return response.copy(result: list);
      }
    } else {
      return response.copy(error: "Data not found!");
    }
  } catch (_) {
    return response.copy(error: _.toString());
  }
}