Published
- 1 min read
flutter singleton
The solution for this is noted below
flutter singleton
Solution
class Singleton {
static final Singleton _instance = Singleton._internal();
factory Singleton() => _instance;
Singleton._internal();
}
// Whenever you need to get the singleton, call its factory constructor, e.g.:
// var singleton = Singleton();
//
// You'll always get the same instance.
Try other methods by searching on the site. That is if this doesn’t work