I'm trying to implement a favorites feature locally in flutter that works both inside the page and on the select page


I’m trying to add a favorites feature with flutter. If you activate it by clicking the Favorites button inside the page, you need to implement it so that the Favorites page marked as Favorite appears in the page selection window. getx was too complex to implement, so I gave up on it. Are there any other attractions or advice pages?

I’ve seen shared_preferences: ^2.0.7, but it’s my first time developing an app, so it’s difficult to develop because there are no examples.


You could have a statefull widget on Page selection where you read from preferences in init state and give that value to the favorite icon (e.g. true icon color is red, false -> white). And pass a function such as (setState(() {favorite = !favorite});) to the second page. Then if user click on the favorite button on page 2 and navigates back, the color will change. Also don’t forget to save it on prefs when you click the iconButton.

Answered By – user14624595

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *