Skip to content

Commit 2c70c26

Browse files
committed
emoticons row builder
1 parent 431155b commit 2c70c26

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed

example/lib/main.dart

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,22 @@ class _MyHomePageState extends State<MyHomePage>
256256

257257
GFRating(
258258
value: _rating,
259-
filledIcon: Icon(
260-
Icons.sentiment_very_satisfied,
261-
color: Colors.green,
262-
size: 50,
263-
),
264-
halfFilledIcon: Icon(
265-
Icons.sentiment_neutral,
266-
color: Colors.amber,
267-
size: 50,
268-
),
269-
defaultIcon: Icon(
270-
Icons.sentiment_very_dissatisfied,
271-
color: Colors.red,
272-
size: 50,
273-
),
259+
// filledIcon: Icon(
260+
// Icons.sentiment_very_satisfied,
261+
// color: Colors.green,
262+
// size: 50,
263+
// ),
264+
// halfFilledIcon: Icon(
265+
// Icons.sentiment_neutral,
266+
// color: Colors.amber,
267+
// size: 50,
268+
// ),
269+
// defaultIcon: Icon(
270+
// Icons.sentiment_very_dissatisfied,
271+
// color: Colors.red,
272+
// size: 50,
273+
// ),
274+
emoticon: true,
274275
onChanged: (value) {
275276
setState(() {
276277
_rating = value;

lib/components/rating/gf_rating.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class GFRating extends StatefulWidget {
2222
this.inputDecorations,
2323
this.margin = const EdgeInsets.symmetric(vertical: 16),
2424
this.padding = const EdgeInsets.symmetric(horizontal: 16),
25+
this.emoticon = false,
2526
}) : assert(value != null);
2627

2728
/// defines total number of rating items
@@ -75,6 +76,8 @@ class GFRating extends StatefulWidget {
7576
/// defines the padding of rating [TextFormField]
7677
final EdgeInsets padding;
7778

79+
final bool emoticon;
80+
7881
@override
7982
_GFRatingState createState() => _GFRatingState();
8083
}
@@ -111,6 +114,43 @@ class _GFRatingState extends State<GFRating> {
111114
);
112115
}
113116

117+
if(widget.emoticon){
118+
if(widget.value == 1){
119+
return Icon(
120+
Icons.sentiment_very_dissatisfied,
121+
color: Colors.red,
122+
size: 40,
123+
);
124+
} else if(widget.value == 2){
125+
return Icon(
126+
Icons.sentiment_dissatisfied,
127+
color: Colors.redAccent,
128+
size: 40,
129+
);
130+
} else if(widget.value == 3){
131+
return Icon(
132+
Icons.sentiment_neutral,
133+
color: Colors.amber,
134+
size: 40,
135+
);
136+
} else if(widget.value == 4){
137+
return Icon(
138+
Icons.sentiment_satisfied,
139+
color: Colors.lightGreen,
140+
size: 40,
141+
);
142+
} else {
143+
return Icon(
144+
Icons.sentiment_satisfied,
145+
color: Colors.green,
146+
size: 40,
147+
);
148+
}
149+
}
150+
151+
152+
153+
114154
return GestureDetector(
115155
onTap: () {
116156
if (widget.onChanged != null) {

0 commit comments

Comments
 (0)