I need to get a number from SharedPreferences and store it in a constant. But i couldn't manage to do it.
SharedPreferences sp = await SharedPreferences.getInstance();
const int index = sp.getInt('index')!;
This code throws this error:
Const variables must be initialized with a constant value.
Try changing the initializer to be a constant expression.
I want to get the data once and never change it again. How can i achieve this?