Skip to content

Instantly share code, notes, and snippets.

View amit-bhandari's full-sized avatar
💻
Writing code, duhhh

Amit Bhandari amit-bhandari

💻
Writing code, duhhh
View GitHub Profile
@theburningmonk
theburningmonk / singleton.dart
Last active September 2, 2022 01:40
Using Dart's factory constructor feature to implement the singleton pattern
class MyClass {
static final MyClass _singleton = new MyClass._internal();
factory MyClass() {
return _singleton;
}
MyClass._internal() {
... // initialization logic here
}