Skip to content

Commit a1646a2

Browse files
committed
user input rating completed
1 parent 5f6147a commit a1646a2

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ class _MyHomePageState extends State<MyHomePage>
268268
width: 50,
269269
color: Colors.amber,
270270
),
271+
ratingController: _ratingController,
271272
textFormRating: true,
272273
spacing: 8,
273274
color: Colors.teal,

lib/components/rating/gf_rating.dart

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6566
class _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

Comments
 (0)