Last active
November 14, 2019 10:20
-
-
Save dafinoer/ee82ee7118c0a2450517e8678b7f08de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//singleton | |
class User{ | |
static final User _user = User._private(); | |
User._private(){} | |
factory User.singleton(int ids){ | |
return _user; | |
} | |
} | |
void main(){ | |
var data = User.singleton(1); | |
var data2 = User.singleton(2); | |
print(data == data2); // true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment