Skip to content

Instantly share code, notes, and snippets.

@yusirdemir
yusirdemir / snippets
Created November 5, 2020 22:04
Snippets
{
"Singleton Lazy": {
"scope": "dart",
"prefix": "lazy",
"body": [
"class $1 {",
"static $1 _instace;",
"static $1 get instance {",
"if (_instace == null) _instace = $1._init();",
"return _instace;",
@yusirdemir
yusirdemir / lazy.dart
Created November 5, 2020 21:48
Lazy Singleton
class NetworkService {
static NetworkService _instace;
static NetworkService get instance {
if (_instace == null) _instace = NetworkService._init();
return _instace;
}
NetworkService._init();
}
@yusirdemir
yusirdemir / eager.dart
Last active March 22, 2021 14:18
Eager Singleton
class NavigationService {
static NavigationService _instace = NavigationService._init();
static NavigationService get instance => _instace;
NavigationService._init();
}