getCount method

Future<int> getCount({
  1. bool withExternal = true,
  2. SourceType? type,
})

Implementation

Future<int> getCount({bool withExternal = true, SourceType? type}) async {
  int count = 0;
  if (type == SourceType.local) {
    String query = '';
    withExternal
        ? query = (this.where.isEmpty
            ? 'SELECT * FROM ${Dynamic.genericModelName(modelList)} ${groupBy}'
            : 'SELECT * FROM ${Dynamic.genericModelName(modelList)} where ${this.where} ${groupBy}')
        : query =
            'SELECT * FROM ${Dynamic.genericModelName(modelList)} ${groupBy}';

    count = await rf.db.count(query);
  } else if (type == SourceType.remote) {
    count = _httpTotalCount;
  } else if (type == SourceType.remote) {
    count = modelList!.length;
  }

  return count;
}