Skip to content

Instantly share code, notes, and snippets.

@darioielardi
Last active February 20, 2019 14:44
Show Gist options
  • Save darioielardi/76ec998bbc6d0ef5d147a23a62c3fe55 to your computer and use it in GitHub Desktop.
Save darioielardi/76ec998bbc6d0ef5d147a23a62c3fe55 to your computer and use it in GitHub Desktop.
[Dart Singleton] Different ways to have a singleton in Dart #singleton
class Singleton {
Singleton._internal();
static final Singleton _singleton = new Singleton._internal();
factory Singleton() => _singleton;
}
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