@@ -6,22 +6,22 @@ class GFRating extends StatefulWidget {
66 const GFRating ({
77 this .itemCount = 5 ,
88 this .spacing = 0.0 ,
9- this .rating = 0.0 ,
9+ this .value = 0.0 ,
1010 this .defaultIcon,
11- this .onRatingChanged ,
11+ this .onChanged ,
1212 this .color,
1313 this .borderColor,
14- this .itemSize = 25 ,
14+ this .size = 30 ,
1515 this .filledIcon,
1616 this .halfFilledIcon,
1717 this .allowHalfRating = true ,
18- this .textFormRating = false ,
18+ this .textForm = false ,
1919 this .suffixIcon,
20- this .ratingController ,
20+ this .controller ,
2121 this .inputDecorations,
2222 this .margin = const EdgeInsets .symmetric (vertical: 16 ),
2323 this .padding = const EdgeInsets .symmetric (horizontal: 16 ),
24- }) : assert (rating != null );
24+ }) : assert (value != null );
2525
2626 /// defines total number of rating items
2727 final int itemCount;
@@ -33,7 +33,7 @@ class GFRating extends StatefulWidget {
3333 final Color borderColor;
3434
3535 /// defines the size of items
36- final double itemSize ;
36+ final double size ;
3737
3838 /// if true, allow half rating of items. Default it will be in true state
3939 final bool allowHalfRating;
@@ -51,19 +51,19 @@ class GFRating extends StatefulWidget {
5151 final double spacing;
5252
5353 /// defines the rating value
54- final double rating ;
54+ final double value ;
5555
5656 /// return current rating whenever rating is updated
57- final RatingChangeCallback onRatingChanged ;
57+ final RatingChangeCallback onChanged ;
5858
5959 /// if true, shows rating [TextFormField] with the rating bar, that allows the user input to show rating
60- final bool textFormRating ;
60+ final bool textForm ;
6161
6262 /// defines the design and funtion of rating [TextFormField] 's suffix icon
6363 final Widget suffixIcon;
6464
6565 /// controls the [TextField] Controller of rating [TextFormField]
66- final TextEditingController ratingController ;
66+ final TextEditingController controller ;
6767
6868 /// defines the [InputDecoration] of rating [TextFormField]
6969 final InputDecoration inputDecorations;
@@ -81,68 +81,68 @@ class GFRating extends StatefulWidget {
8181class _GFRatingState extends State <GFRating > {
8282 Widget buildRatingBar (BuildContext context, int index) {
8383 Widget icon;
84- if (index >= widget.rating ) {
84+ if (index >= widget.value ) {
8585 icon = widget.defaultIcon != null
8686 ? widget.defaultIcon
8787 : Icon (
8888 Icons .star_border,
8989 color: widget.borderColor ?? Theme .of (context).primaryColor,
90- size: widget.itemSize ,
90+ size: widget.size ,
9191 );
92- } else if (! widget.textFormRating
93- ? index > widget.rating - (widget.allowHalfRating ? 0.5 : 1.0 ) &&
94- index < widget.rating
95- : index + 1 == widget.rating + 0.5 ) {
92+ } else if (! widget.textForm
93+ ? index > widget.value - (widget.allowHalfRating ? 0.5 : 1.0 ) &&
94+ index < widget.value
95+ : index + 1 == widget.value + 0.5 ) {
9696 icon = widget.halfFilledIcon != null
9797 ? widget.halfFilledIcon
9898 : Icon (
9999 Icons .star_half,
100100 color: widget.color ?? Theme .of (context).primaryColor,
101- size: widget.itemSize ,
101+ size: widget.size ,
102102 );
103103 } else {
104104 icon = widget.filledIcon != null
105105 ? widget.filledIcon
106106 : Icon (
107107 Icons .star,
108108 color: widget.color ?? Theme .of (context).primaryColor,
109- size: widget.itemSize ,
109+ size: widget.size ,
110110 );
111111 }
112112
113113 return GestureDetector (
114114 onTap: () {
115- if (widget.onRatingChanged != null ) {
116- widget.onRatingChanged (index + 1.0 );
115+ if (widget.onChanged != null ) {
116+ widget.onChanged (index + 1.0 );
117117 }
118118 },
119119 onHorizontalDragUpdate: (dragDetails) {
120120 final RenderBox box = context.findRenderObject ();
121121 final _pos = box.globalToLocal (dragDetails.globalPosition);
122- final i = _pos.dx / widget.itemSize ;
122+ final i = _pos.dx / widget.size ;
123123 var newRating = widget.allowHalfRating ? i : i.round ().toDouble ();
124124 if (newRating > widget.itemCount) {
125125 newRating = widget.itemCount.toDouble ();
126126 }
127127 if (newRating < 0 ) {
128128 newRating = 0.0 ;
129129 }
130- if (widget.onRatingChanged != null ) {
131- widget.onRatingChanged (newRating);
130+ if (widget.onChanged != null ) {
131+ widget.onChanged (newRating);
132132 }
133133 },
134134 child: icon,
135135 );
136136 }
137137
138138 @override
139- Widget build (BuildContext context) => widget.textFormRating
139+ Widget build (BuildContext context) => widget.textForm
140140 ? Column (children: < Widget > [
141141 Container (
142142 margin: widget.margin,
143143 padding: widget.padding,
144144 child: TextFormField (
145- controller: widget.ratingController ,
145+ controller: widget.controller ,
146146 keyboardType: TextInputType .number,
147147 decoration: widget.inputDecorations == null
148148 ? InputDecoration (
0 commit comments