That title error is pointed on this line:
Text('${intData['summary']['intrested']}')
I want to display here data from backend, but I don't know how to accomplish that I am getting this error, but this is not null.
Here is my code:
var intData;
Future<Map> loadMyFriends(String eventId) async {
var request = await EndPoints.interest(eventId, userId);
print(request.body);
intData = jsonDecode(request.body)['data'] as Map;
return jsonDecode(request.body)['data'];
}
@override
void initState() {
super.initState();
userId = widget.userId;
loadMyFriends(widget.partyMap['id']).then((value) => print('$intData'));
}
@override
void didUpdateWidget(SquareBoxMovableBuilder oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.partyMap != oldWidget.partyMap) {
loadMyFriends(widget.partyMap['id']);
print(intData);
}
}
and here are console prints what intData contains:
//print(request.body) in loadMyFriends function
{"data":{"intrested":null,"participate":null,"summary":{"intrested":0,"participate":0},"friends":{"list":[],"sum":0}}}
//print(intData) in initState
{intrested: null, participate: null, summary: {intrested: 0, participate: 0}, friends: {list: [], sum: 0}}
//print(intData) in didUpdateWidget
{intrested: null, participate: null, summary: {intrested: 0, participate: 0}, friends: {list: [], sum: 0}}
I tried to do this with FutureBuilder but I had same result. How to fix it or how to do it? How to display data downloaded from backend every time when I open this widget?