I need help managing state between pages.. In the first page I update my map to change a value. When I print this value it works but in my other page the value is still the first value I gave.. How can I do to keep this value even in my second page?
Setting the state : I update the value of color into a map depending on the user input
if (country.containsKey(guess)) {
setState(() {
_countryName.add(guess);
countries_info[guess]!["color"] = "Colors.green";
Second page : Here I want to change the color of the text depending on the value I changed in the first file
Widget build(BuildContext context) {
return Expanded(
child: GridView.builder(
itemCount: continentCountry.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 3,
mainAxisSpacing: 3,
childAspectRatio: 5),
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: BoxDecoration(
border: Border.all(width: 3, color: splashBackground),
color: purpleList,
),
alignment: Alignment.center,
height: 10,
child: Text(continentCountry[index], style: setColors()),
);
}),
);
}
}
setColors() {
for (final value in countries_info.values) {
print(value["color"]);
if (value["color"] == "Colors.green") {
return TextStyle(color: Colors.green);
} else {
return TextStyle(color: Colors.red);
}
}
}