Last active
February 20, 2019 14:44
-
-
Save darioielardi/76ec998bbc6d0ef5d147a23a62c3fe55 to your computer and use it in GitHub Desktop.
[Dart Singleton] Different ways to have a singleton in Dart #singleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton { | |
Singleton._internal(); | |
static final Singleton _singleton = new Singleton._internal(); | |
factory Singleton() => _singleton; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final singleton = new Singleton._internal(); | |
class Singleton { | |
Singleton._internal(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment