🐛 [cloud_firestore] Calling Query.aggregate(average('value')).get()
on an empty collection throws an exception
#12229
Labels
platform: android
Issues / PRs which are specifically for Android.
plugin: cloud_firestore
resolution: fixed
A fix has been merged or is pending merge from a PR.
type: bug
Something isn't working
Bug report
This bug happens on Android and web (not tested on iOS). It works ok when there is at least one item but crashes if no item are present. sum and count works fine.
Steps to reproduce
Try the following on a collection (empty or not)
If the collection is not empty (and at least one record has a
value
field), it works fine, otherwise it throws a Platform exceptionExpected behavior
While the average value or the resulting snapshot should be null (i.e. cannot get an average), the request should not crash.
Additional context
Tested on Android and Web. A similar request using the REST API or on node.js works fine (and reports a null average value)
Flutter doctor
Flutter dependencies
The text was updated successfully, but these errors were encountered: