getTotalNoOfProducts method
Get the total number of products in the database
Implementation
Future<Map<ProductType, int>> getTotalNoOfProducts() async {
final Map<ProductType, int> result = <ProductType, int>{};
final List<Map<String, dynamic>> queryResults = await localDatabase.database
.query(_TABLE_PRODUCT, columns: _columns);
for (final Map<String, dynamic> row in queryResults) {
final Product product = _getProductFromQueryResult(row);
final ProductType productType = product.productType ?? ProductType.food;
final int? count = result[productType];
result[productType] = 1 + (count ?? 0);
}
return result;
}