Dart Crea Singleton con parámetros
class Peoples {
int id;
String name;
static final Peoples _inst = Peoples._internal();
Peoples._internal();
factory Peoples(int id, String name) {
_inst.id = id;
_inst.name = name;
return _inst;
}
}
void main() {
print("Instance of = " + Peoples(0, "Dylan").name);
print("Instance of = " + Peoples(1, "Joe").name);
print("Instance of = " + Peoples(2, "Maria").name);
}
Niamul Hasan