Skip to content

Commit 55f14d5

Browse files
committed
rating definations completed
1 parent 492b308 commit 55f14d5

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ class _MyHomePageState extends State<MyHomePage>
216216

217217
GFRating(
218218
rating: rating,
219-
// iconSize: 65,
219+
// itemSize: 65,
220220
filledIcon: Icons.star,
221221
halfFilledIcon: Icons.star_half,
222222
defaultIcon: Icons.star_border,
223223
itemCount: 5,
224224
allowHalfRating: false,
225-
// spacing: 2.0,
225+
spacing: 2.0,
226226
color: Colors.teal,
227227
borderColor: Colors.tealAccent,
228228
onRatingChanged: (value) {

lib/components/rating/gf_rating.dart

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,69 @@ class GFRating extends StatelessWidget {
1212
this.onRatingChanged,
1313
this.color,
1414
this.borderColor,
15-
this.iconSize = 25,
15+
this.itemSize = 25,
1616
this.filledIcon,
1717
this.halfFilledIcon,
1818
this.allowHalfRating = true,
1919
}) {
2020
assert(this.rating != null);
2121
}
2222

23+
/// defines total number of rating items
2324
final int itemCount;
24-
final double rating;
25-
final RatingChangeCallback onRatingChanged;
25+
26+
/// defines the color of items
2627
final Color color;
28+
29+
/// defines the border color of [halfFilledIcon]
2730
final Color borderColor;
28-
final double iconSize;
31+
32+
/// defines the size of items
33+
final double itemSize;
34+
35+
/// if true, allow half rating of items. Default it will be in true state
2936
final bool allowHalfRating;
37+
38+
/// defines the items when filled
3039
final IconData filledIcon;
40+
41+
/// defines the items when half-filled
3142
final IconData halfFilledIcon;
32-
final IconData defaultIcon; //this is needed only when having fullRatedIconData && halfRatedIconData
43+
44+
/// defines the default items, when having filledIcon && halfFilledIcon
45+
final IconData defaultIcon;
46+
47+
/// defines the space between items
3348
final double spacing;
3449

50+
/// defines the rating value
51+
final double rating;
52+
53+
/// return current rating whenever rating is updated
54+
final RatingChangeCallback onRatingChanged;
55+
56+
3557

3658
Widget buildRatingBar(BuildContext context, int index) {
3759
Icon icon;
3860
if (index >= rating) {
3961
icon = Icon(
4062
defaultIcon != null ? defaultIcon : Icons.star_border,
4163
color: borderColor ?? Theme.of(context).primaryColor,
42-
size: iconSize,
64+
size: itemSize,
4365
);
4466
} else if (index > rating - (allowHalfRating ? 0.5 : 1.0) &&
4567
index < rating) {
4668
icon = Icon(
4769
halfFilledIcon != null ? halfFilledIcon : Icons.star_half,
4870
color: color ?? Theme.of(context).primaryColor,
49-
size: iconSize,
71+
size: itemSize,
5072
);
5173
} else {
5274
icon = Icon(
5375
filledIcon != null ? filledIcon : Icons.star,
5476
color: color ?? Theme.of(context).primaryColor,
55-
size: iconSize,
77+
size: itemSize,
5678
);
5779
}
5880

0 commit comments

Comments
 (0)