I've applied the singleton pattern as in this issue and tried to accept a parameter using the method in this issue. But it gives me this error:
Non-nullable instance field 'id' must be initialized. Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'
So where is the issue?
Here is my code:
static final Singleton _inst = Singleton._internal();
int id;
Singleton._internal() {
// some logic
}
factory Singleton({required int id}) {
_inst.id = id;
return _inst;
}