[英]How To Remember Pageview Widget Last Visited Page
I am building an Android App using Flutter and Dart.我正在使用 Flutter 和 Dart 构建一个 Android 应用程序。
In this app, I am using a Pageview Widget, the user interact with it, scroll some pages, now when the user leaves the Pageview Widget and go to some other page do some activity there, the user when comes back to the Pageview Widget, the widget starts showing the dynamically created pages, it starts with the first page, here I want to start the index from the page which was last visited by the user.在这个应用程序中,我使用的是 Pageview Widget,用户与其交互,滚动一些页面,现在当用户离开 Pageview Widget 并转到其他页面时,在那里做一些活动,当用户回到 Pageview Widget 时,小部件开始显示动态创建的页面,它从第一页开始,在这里我想从用户上次访问的页面开始索引。
I have thought of a solution to store the last visited page on DB and retrieving it when the user comes to Pageview Widget and updating it on every page scroll.我想到了一个解决方案,将最后访问的页面存储在 DB 上,并在用户访问 Pageview Widget 时检索它并在每个页面滚动时更新它。 Is this a good solution?
这是一个很好的解决方案吗? Or there is another way to accomplish this thing.
或者有另一种方法来完成这件事。
最好的解决方案是将当前页面 id 保存在 shared_preferences 中,然后在用户再次访问该页面时检索它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.