i just want to know how to maintain pages state in flutter changenotifier provider like for example if we have ecommerce app and i entered a product details page where I can add this product to cart or add it to Wishlist , when i again enters the same product page from any where on the app like from cart or Wishlist or even from random carousel inside the app I want to see the pages state the same , but here in my problem when i enter the product page it shows initial state with no add to cart and no Wishlist add so what should i do ?
i tried putting variables to maintain page state but it didn't work, i want one good solution for this
You can simply store the value of the added Product in the SharedPreferences. And whenever you visit a Product page, you can fetch the list of Products stored in the SharedPreferences and compare that list with this particular product or list of products to know if the product is already in the cart or not.
This solution will work regardless of the State management pattern that you are using.