Skip to content

Instantly share code, notes, and snippets.

@dafinoer
Last active November 14, 2019 10:20
Show Gist options
  • Save dafinoer/ee82ee7118c0a2450517e8678b7f08de to your computer and use it in GitHub Desktop.
Save dafinoer/ee82ee7118c0a2450517e8678b7f08de to your computer and use it in GitHub Desktop.
//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