When accessing a flutter page, I'm creating a graph (syncfusion) and 2 rows with values downloaded from some API.
I create an empty page, then, when the data is loaded, I set the variables with the respective data and call setState(() {walletRows=wallet.getWallet();});
to update the rows variable with the data for the rows I mentioned in the beginning.
Problem: the graph is actually generated but the rows are not created (if I change page or hot reload, the rows appears)
In initState i call loadPageData
which loads the data in 2 variables.
@override
initState() {
loadPageData();
_pageController = PageController();
super.initState();
}
This is the loadPageData func
Future<void> loadPageData() async {
this._chartData = await getChartData(); // variable to feed sfcartesianchart
const storage = FlutterSecureStorage(); // getting token for api call
String token = await storage.read(key: 'token') as String;
var wallet = WalletRow();
wallet.addText(token);
setState(() {walletRows=wallet.getWallet();}); //setting state with updated walletrows
}
Within a Column i have another Column where the children are taken from walletRows.
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
textAlign: TextAlign.left,
"Rows",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color:
Color.fromARGB(255, 113, 113, 113)),
),
Column(children:walletRows)
]),
As requested, here is the page (just part of it, else it would be too long): https://pastebin.com/cVC2pdhX
UPDATE
I realized that if I add a Button with setState on the onPressed event, the rows get correctly added; so it seems there is a problem with the first setState although I still can't find a solution to it.