0

This list is inside a provider:

List<DailyData> _storeDataByDate = [];
List<DailyData> _reversedstoreDataByDate = _storeDataByDate.reversed.toList();

But the bottom line is marked and shows the message: The instance member '_storeDataByDate' can't be accessed in an initializer. Try replacing the reference to the instance member with a different expression.

Eric Melo
  • 45
  • 8
  • I guess the two lines are from a `class` definition? – julemand101 Apr 23 '21 at 17:18
  • Also, I am maybe a little confused about what you are trying to achieve? You are aware that the second list will be a new list which does not have any attachment to the first? So when you add a new element to `_storeDataByDate` it will not be added automatically to `_reversedstoreDataByDate` – julemand101 Apr 23 '21 at 17:20
  • See https://stackoverflow.com/a/64548861/. – jamesdlin Apr 23 '21 at 19:28

1 Answers1

0

You could just do it as a function instead of a variable.

  List<DailyData> _reversedstoreDataByDate() => _storeDataByDate.reversed.toList();
some_dude
  • 16
  • 1