-1

I was trying to add pagination to a web app using Riverpod but it seems that doesn't maintain state after reloading the page. Then I tried with the official counter app example, and after increasing the count and reloading the count does reset to 0.

Any ideas why this is happening?

chessasuke
  • 17
  • 1
  • 6

1 Answers1

1

Flutter web cannot hot-reload, only hot-restart, so you will be running main() from the top again.

Randal Schwartz
  • 39,428
  • 4
  • 43
  • 70
  • I referred to reloading/refreshing the browser – chessasuke Jan 11 '21 at 22:54
  • Yes, and I was answering you. :) How is my answer unclear? – Randal Schwartz Jan 11 '21 at 22:54
  • Sorry, I am a beginner in flutter, but is it refreshing the page with the button in the browser the same as hot restarting in the IDE? – chessasuke Jan 11 '21 at 23:09
  • No. On the web, refreshing the browser, or hitting the "hot restart" button in the IDE do the same thing. And at least for now, "hot reload" in the IDE also does the same thing, because hot-reload doesn't work yet for flutter web. – Randal Schwartz Jan 11 '21 at 23:11
  • I see, thank u. Is there a correct approach to maintain state after refreshing the browser? In any website after refreshing, the same page is displayed this is what I want to achieve. – chessasuke Jan 11 '21 at 23:18
  • Not yet, but Flutter Web is only in beta. Lots to still make working. – Randal Schwartz Jan 11 '21 at 23:20
  • 1
    just wanted to share, Navigator 2.0 does solve this problem I faced – chessasuke Jan 14 '21 at 23:01
  • Also during development you can use iOS or Android to keep using hot reload once you implement your main future productively you can test one more time on web. Some people use flutter desktop to be able to change screen size and at the same time keep hot reload – sultanmyrza Jul 18 '21 at 03:03
  • @chessasuke are you able to provide any specifics as to how the issue is resolved with Navigator 2.0, or a link to a resource? – Leland Reardon Jul 28 '23 at 08:45