Skip to content

Instantly share code, notes, and snippets.

@karzia
Last active December 28, 2022 04:18
Show Gist options
  • Save karzia/c7a43676032d8af0f54f539dc0a4dbfa to your computer and use it in GitHub Desktop.
Save karzia/c7a43676032d8af0f54f539dc0a4dbfa to your computer and use it in GitHub Desktop.
Singleton in Dart
//In Dart
//You can make Singleton class easily.
class FooManager {
final _inst = FooManager._internal();
FooManager._internal();
factory FooManager() => _inst;
//for test
testPrint(){
print("test");
}
}
//Usage
test(){
FooManager().testPrint();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment