I have a integar list like [1,2,3,4] and I a need to make a new list as a String list like ['1','2','3','4'], how can I convert it easily? I need to do this for using Sharedpreferences getStringList command.
List<int> selectedAmount = [];
IconButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => BodyPage(goal: widget.goal)));
waterAmount = amount[index];
print(' secilen = $waterAmount');
selectedAmount.add(waterAmount);
setState(() => this.index = index);},
icon: Icon(
Icons.add,
size: 28,
color: Colors.blueGrey,))
and the other page:
List<int> totalList = selectedAmount;
List<String> totalStringList = totalList.map((e) => e.toString()).toList();
"The instance member 'totalList' can't be accessed in an initializer." im getting this error.