calculate method
Implementation
List<Map<String, dynamic>> calculate(String field, num value,
{String operator = '+'}) {
final operatorMap = {'+': (a, b) => a + b, '-': (a, b) => a - b};
final calculatedDocuments = collection.values.map((document) {
if (document[field] is num) {
document[field] = operatorMap[operator]!(document[field], value);
}
return document;
}).toList();
return List<Map<String, dynamic>>.from(calculatedDocuments);
}