filter method

Future<List<XData>> filter([
  1. dynamic field,
  2. dynamic value
])

Implementation

Future<List<XData>> filter([field, value]) async {
  if (field == null && value == null) {
    return await _getAllDocs();
  } else if (fields.where((element) => element.field == field).isEmpty) {
    throw Exception('Field $field not found');
  }
  var dataSet = await _getAllDocs();
  return dataSet.where((element) => element.data[field] == value).toList();
}