Skip to content

Commit 38cdc59

Browse files
committed
rating bar icon changed and tested
1 parent 2543cec commit 38cdc59

2 files changed

Lines changed: 8 additions & 25 deletions

File tree

example/lib/main.dart

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -218,25 +218,10 @@ class _MyHomePageState extends State<MyHomePage>
218218
GFRating(
219219
value: _rating,
220220
// size: 50,
221-
// filledIcon: Image.asset(
222-
// 'lib/assets/heart.png',
223-
// height: 50,
224-
// width: 50,
225-
// color: Colors.amber,
226-
// ),
227-
// halfFilledIcon: Image.asset(
228-
// 'lib/assets/heart_half.png',
229-
// height: 50,
230-
// width: 50,
231-
// color: Colors.amber,
232-
// ),
233-
// defaultIcon: Image.asset(
234-
// 'lib/assets/heart_border.png',
235-
// height: 50,
236-
// width: 50,
237-
// color: Colors.amber,
238-
// ),
239-
// spacing: 8,
221+
filledIcon: Icon(Icons.done_outline, size: 40, color: Colors.teal,),
222+
halfFilledIcon: Icon(Icons.done_all, size: 40, color: Colors.teal.withOpacity(0.75),),
223+
defaultIcon: Icon(Icons.done, size: 40, color: Colors.teal.withOpacity(0.25),),
224+
spacing: 8,
240225
// color: Colors.teal,
241226
// borderColor: Colors.tealAccent,
242227
// allowHalfRating: false,

lib/components/rating/gf_rating.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,14 @@ class _GFRatingState extends State<GFRating> {
8484

8585
Widget buildRatingBar(BuildContext context, int index) {
8686

87-
print('jkkl ${GFSizesClass.getGFSize(widget.size)}');
88-
8987
Widget icon;
9088
if (index >= widget.value) {
9189
icon = widget.defaultIcon != null
9290
? widget.defaultIcon
9391
: Icon(
9492
Icons.star_border,
9593
color: widget.borderColor ?? Theme.of(context).primaryColor,
96-
size: GFSizesClass.getGFSize(widget.size).toDouble(),
94+
size: GFSizesClass.getGFSize(widget.size),
9795
);
9896
} else if (!widget.textForm
9997
? index > widget.value - (widget.allowHalfRating ? 0.5 : 1.0) &&
@@ -104,15 +102,15 @@ class _GFRatingState extends State<GFRating> {
104102
: Icon(
105103
Icons.star_half,
106104
color: widget.color ?? Theme.of(context).primaryColor,
107-
size: GFSizesClass.getGFSize(widget.size).toDouble(),
105+
size: GFSizesClass.getGFSize(widget.size),
108106
);
109107
} else {
110108
icon = widget.filledIcon != null
111109
? widget.filledIcon
112110
: Icon(
113111
Icons.star,
114112
color: widget.color ?? Theme.of(context).primaryColor,
115-
size: GFSizesClass.getGFSize(widget.size).toDouble(),
113+
size: GFSizesClass.getGFSize(widget.size),
116114
);
117115
}
118116

@@ -125,7 +123,7 @@ class _GFRatingState extends State<GFRating> {
125123
onHorizontalDragUpdate: (dragDetails) {
126124
final RenderBox box = context.findRenderObject();
127125
final _pos = box.globalToLocal(dragDetails.globalPosition);
128-
final i = _pos.dx / widget.size;
126+
final i = _pos.dx / GFSizesClass.getGFSize(widget.size);
129127
var newRating = widget.allowHalfRating ? i : i.round().toDouble();
130128
if (newRating > widget.itemCount) {
131129
newRating = widget.itemCount.toDouble();

0 commit comments

Comments
 (0)