Why is this initialization of trailing fields wrong in Dart?
I have a simple class with two final fields, one of which is a map for storing data and the other is a step function that updates the data when called:
class Data { //for each name a list of observations final Map<String,List<double>> _dataMap; /** * the update step */ final Step _updateStep;
Step
is just a typedef
.
Now I need a constructor that has one parameter: a function that takes a reference Map<...>
and returns a new one Step
. It seems logical to me, the updater needs a map link to update it.
Why then does this constructor fail?
Data(Step initializer(Map<String,List<double>> dataReferences)) : _dataMap = new Map(), _updateStep = initializer(_dataMap);
Error in the second step
illegal implicit access to the receiver 'this';
What? How is it leaked? How to fix it?
+3
source to share
2 answers