// This Main() Function of Dart
void main(){
//****************************************
MySingleton mS=MySingleton();
mS.doSomething();
mS.name="Surya Prakash";
mS.age="29";
//******************************************************
}
//*********************** Singlton Class ***********************************
class MySingleton {
// Private constructor to prevent external instantiation
MySingleton._privateConstructor();
// The single instance of the class
static final MySingleton _instance = MySingleton._privateConstructor();
// Factory constructor to provide access to the instance
factory MySingleton() {
return _instance;
}
// Add your methods and properties here
void doSomething() {
print('Singleton is doing something);
}
// Create Varialbles
String? name;
String? age;
}
Comments
Post a Comment