File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -100,20 +100,22 @@ class FavoriteWidget extends StatefulWidget{
100
100
101
101
class FavoriteWidgetState extends State <FavoriteWidget >{
102
102
103
- bool isFavorite = false ;
103
+ bool isFavorite = true ;
104
104
int count = 41 ;
105
105
106
106
@override
107
107
Widget build (BuildContext context) {
108
- // TODO: implement build
108
+
109
109
return Container (
110
110
child: Row (
111
- children: < Widget > [
111
+ mainAxisSize: MainAxisSize .min,
112
+ crossAxisAlignment: CrossAxisAlignment .center,
113
+ children: [
112
114
IconButton (
113
115
onPressed: setFavorite,
114
116
icon: IconButton (
115
- icon: (isFavorite ? Icon (Icons .star) : Icon (Icons .star_border)),
116
117
color: Colors .red,
118
+ icon: (isFavorite ? Icon (Icons .star) : Icon (Icons .star_border)),
117
119
),
118
120
),
119
121
Text ('$count ' )
@@ -124,15 +126,15 @@ class FavoriteWidgetState extends State<FavoriteWidget>{
124
126
}
125
127
126
128
void setFavorite (){
127
-
128
- print ( "click" );
129
- if ( isFavorite){
130
- isFavorite = false ;
131
- count = 40 ;
132
- } else {
133
- isFavorite = true ;
134
- count = 41 ;
135
- }
129
+ setState (() {
130
+ if (isFavorite){
131
+ isFavorite = false ;
132
+ count = 40 ;
133
+ } else {
134
+ isFavorite = true ;
135
+ count = 41 ;
136
+ }
137
+ });
136
138
}
137
139
138
140
}
You can’t perform that action at this time.
0 commit comments