Skip to content

Commit 6118962

Browse files
committed
rating dynamic size added for icon
1 parent 45a11f1 commit 6118962

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

lib/components/rating/gf_rating.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:getflutter/getflutter.dart';
23

34
typedef RatingChangeCallback = void Function(double rating);
45

@@ -11,7 +12,7 @@ class GFRating extends StatefulWidget {
1112
this.onChanged,
1213
this.color,
1314
this.borderColor,
14-
this.size = 30,
15+
this.size = GFSize.medium,
1516
this.filledIcon,
1617
this.halfFilledIcon,
1718
this.allowHalfRating = true,
@@ -33,7 +34,7 @@ class GFRating extends StatefulWidget {
3334
final Color borderColor;
3435

3536
/// defines the size of items
36-
final double size;
37+
final dynamic size;
3738

3839
/// if true, allow half rating of items. Default it will be in true state
3940
final bool allowHalfRating;
@@ -79,15 +80,20 @@ class GFRating extends StatefulWidget {
7980
}
8081

8182
class _GFRatingState extends State<GFRating> {
83+
84+
8285
Widget buildRatingBar(BuildContext context, int index) {
86+
87+
print('jkkl ${GFSizesClass.getGFSize(widget.size)}');
88+
8389
Widget icon;
8490
if (index >= widget.value) {
8591
icon = widget.defaultIcon != null
8692
? widget.defaultIcon
8793
: Icon(
8894
Icons.star_border,
8995
color: widget.borderColor ?? Theme.of(context).primaryColor,
90-
size: widget.size,
96+
size: GFSizesClass.getGFSize(widget.size).toDouble(),
9197
);
9298
} else if (!widget.textForm
9399
? index > widget.value - (widget.allowHalfRating ? 0.5 : 1.0) &&
@@ -98,15 +104,15 @@ class _GFRatingState extends State<GFRating> {
98104
: Icon(
99105
Icons.star_half,
100106
color: widget.color ?? Theme.of(context).primaryColor,
101-
size: widget.size,
107+
size: GFSizesClass.getGFSize(widget.size).toDouble(),
102108
);
103109
} else {
104110
icon = widget.filledIcon != null
105111
? widget.filledIcon
106112
: Icon(
107113
Icons.star,
108114
color: widget.color ?? Theme.of(context).primaryColor,
109-
size: widget.size,
115+
size: GFSizesClass.getGFSize(widget.size).toDouble(),
110116
);
111117
}
112118

0 commit comments

Comments
 (0)