Skip to content

Commit

Permalink
Merge branch 'p30arena-patch-1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
thangmam committed Dec 26, 2019
2 parents 394aabd + c022ba6 commit e2ac09d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/smooth_star_rating.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ class SmoothStarRating extends StatelessWidget {
}

Widget buildStar(BuildContext context, int index) {
final direction = Directionality.of(context);
Icon icon;
if (index >= rating) {
icon = new Icon(
Icons.star_border,
color: borderColor ?? Theme.of(context).primaryColor,
size: size ?? 25.0,
);
} else if (index > rating - (allowHalfRating ? 0.5 : 1.0) &&
} else if (index >= rating - (allowHalfRating ? 0.5 : 1.0) &&
index < rating) {
icon = new Icon(
Icons.star_half,
Expand All @@ -55,7 +56,10 @@ class SmoothStarRating extends StatelessWidget {
onHorizontalDragUpdate: (dragDetails) {
RenderBox box = context.findRenderObject();
var _pos = box.globalToLocal(dragDetails.globalPosition);
var i = _pos.dx / size;
var i = ((direction == TextDirection.rtl)
? (box.size.width - _pos.dx)
: _pos.dx) /
size;
var newRating = allowHalfRating ? i : i.round().toDouble();
if (newRating > starCount) {
newRating = starCount.toDouble();
Expand Down

0 comments on commit e2ac09d

Please sign in to comment.