Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter singleton

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.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flutter #singleton
ADD COMMENT
Topic
Name
2+4 =