Skip to content

Instantly share code, notes, and snippets.

View amit-bhandari's full-sized avatar
💻
Inhaling oxygen, exhaling co2

Amit Bhandari amit-bhandari

💻
Inhaling oxygen, exhaling co2
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
}