@@ -17,6 +17,7 @@ class GFRating extends StatefulWidget {
1717 this .allowHalfRating = true ,
1818 this .textFormRating = false ,
1919 this .suffixIcon,
20+ this .ratingController,
2021 }) : assert (rating != null );
2122
2223 /// defines total number of rating items
@@ -56,22 +57,14 @@ class GFRating extends StatefulWidget {
5657
5758 final Widget suffixIcon;
5859
59- final Controller ratingController;
60+ final TextEditingController ratingController;
6061
6162 @override
6263 _GFRatingState createState () => _GFRatingState ();
6364}
6465
6566class _GFRatingState extends State <GFRating > {
6667
67- final _ratingController = TextEditingController ();
68-
69- @override
70- void initState () {
71- super .initState ();
72- _ratingController.text = '4.5' ;
73- }
74-
7568 Widget buildRatingBar (BuildContext context, int index) {
7669 Widget icon;
7770 if (index >= widget.rating) {
@@ -137,7 +130,7 @@ class _GFRatingState extends State<GFRating> {
137130 margin: const EdgeInsets .symmetric (vertical: 16 ),
138131 padding: const EdgeInsets .symmetric (horizontal: 16 ),
139132 child: TextFormField (
140- controller: ,
133+ controller: widget.ratingController ,
141134 keyboardType: TextInputType .number,
142135 decoration: InputDecoration (
143136 border: const OutlineInputBorder (),
0 commit comments