[英]What is the best way to share variables with flutter?
我有这些变量,我想与另一个屏幕共享它,除了 Pushing them 之外,共享它们的最佳方式是什么?
You could try working with Singletons, store your variables in a singleton class and share them across screens.您可以尝试使用单例,将变量存储在单例类中并跨屏幕共享。
class YourClass {
static YourClass _instance;
YourClass._();
static YourClass get instance => _instance = _instance ?? YourClass._();
// Your instance variables that you want to share can go here
var isVisible = false
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.