Flutter:全局保存列表的方式是什么,以便在浏览我的应用程序后保持状态?
Flutter: What's the way to save a list globally, so state is maintained after navigating around my app?
我基本上有一个待办事项样式列表,用户可以在其中创建列表项并显示在屏幕上的列表中。当我向后导航到我的主菜单和 return 时,该列表未保存。我保存列表状态是这样的:
class CustomExScreenState extends State<CustomExScreen>
with TickerProviderStateMixin {
List<Exerciselist> items = new List<Exerciselist>();
GlobalKey<AnimatedListState> animatedListKey = GlobalKey<AnimatedListState>();
AnimationController emptyListController;
我是否需要为我可以导航到的每个 'screen' 复制此代码?是 better/easier 方式吗?如果问题不清楚,我深表歉意,我是编程新手,有点迷茫。如果有人能给我一个正确方向的观点,将不胜感激!谢谢
我基本上有一个待办事项样式列表,用户可以在其中创建列表项并显示在屏幕上的列表中。当我向后导航到我的主菜单和 return 时,该列表未保存。我保存列表状态是这样的:
class CustomExScreenState extends State<CustomExScreen>
with TickerProviderStateMixin {
List<Exerciselist> items = new List<Exerciselist>();
GlobalKey<AnimatedListState> animatedListKey = GlobalKey<AnimatedListState>();
AnimationController emptyListController;
我是否需要为我可以导航到的每个 'screen' 复制此代码?是 better/easier 方式吗?如果问题不清楚,我深表歉意,我是编程新手,有点迷茫。如果有人能给我一个正确方向的观点,将不胜感激!谢谢