I am programming in Flutter using Dart 2.1.0, and come across this situation:
mixin Salt {
final int pinches; // Immutable, and I want to delay initialization.
// Cannot declare constructors for mixin
}
class Meat with Salt {
Meat(int pinches) ... // How to initialize it?
}
Salt
has no constructor, so I cannot use initializer list. pinches
is final
, so I cannot set it in Meat
's constructor.
I don't want to make Salt
a class because Meat
may need to extend from something else.
And I want to keep pinches
immutable.
Any way to do it? Thanks in advance.