fix(mobile): star rating always defaults to 0 (#27157)

This commit is contained in:
Yaros 2026-03-23 15:56:27 +01:00 committed by GitHub
parent bf065a834f
commit e2eb03d3a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,6 +39,16 @@ class _RatingBarState extends State<RatingBar> {
_currentRating = widget.initialRating;
}
@override
void didUpdateWidget(covariant RatingBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.initialRating != widget.initialRating && _currentRating != widget.initialRating) {
setState(() {
_currentRating = widget.initialRating;
});
}
}
void _updateRating(Offset localPosition, bool isRTL, {bool isTap = false}) {
final totalWidth = widget.itemCount * widget.itemSize + (widget.itemCount - 1) * widget.starPadding;
double dx = localPosition.dx;