Division by zero
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Search the Flutter project for ratingCount and the average-rating calculation, then reproduce the crash with a zero count. Update the calculation so the zero-count case is handled without producing Infinity or NaN, and verify that the app no longer crashes when no ratings exist.
Written by the indexing model from the issue text.
Description
🐛 Describe the bug
The application crashes when calculating the average rating due to a division by zero error. This occurs when ratingCount is 0, which leads to an invalid division operation.
Steps to Reproduce
Ensure ratingCount is 0
Trigger any code path that calculates the average rating
The app crashes immediately
double ratingTotal = 0;
int ratingCount = 0;
double averageRating = ratingTotal / ratingCount; // ❌ Crash here
print(averageRating);
Unsupported operation: Infinity or NaN toInt
#0 double.toInt (dart:core-patch/double.dart:xxx)
#1 YourWidget.build (package:your_app/your_widget.dart:xx)
#2 StatelessElement.build (package:flutter/src/widgets/framework.dart:xxx)
#3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:xxx)
Expected Behavior
The app should handle cases where ratingCount == 0 gracefully, without crashing.
💡 Suggested Fix
Add a guard condition before division:
double averageRating = ratingCount == 0
? 0
: ratingTotal / ratingCount;
- Dominant language
- Dart
- Stars
- 342
- Forks
- 350
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/Resonate
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AOSSIE-Org/Resonate#803 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
AOSSIE-Org/Resonate#792 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AOSSIE-Org/Resonate#789 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AOSSIE-Org/Resonate#780 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AOSSIE-Org/Resonate#762 · 2 comments ·
All issues in AOSSIE-Org/Resonate
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
code quality good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Suwayomi/Suwayomi-Tsumiru#479 ·
-
Build Failure: agora_rtc_engine compiled against android-31 while dependencies require android-34+ Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
conceptadev/noir#95 ·