I am working on a food delivery rider application with mvc_pattern. I want to get order details, rider current location and customer delivery address (i-e: Source to destination). I am getting these values by api calls. When I call setState after getting the values, the widget tree is not being rebuilt. When I debug the code, it says 'setState() callback argument returned a Future.'
await getOrderDetailsApi(orderid).then((value) {
orderDetails = value!;
ScaffoldMessenger.of(state!.context).showSnackBar(SnackBar(
content: Text(
S.of(state!.context).notificationWasRemoved,
),
));
}).catchError((e) {
ScaffoldMessenger.of(state!.context).showSnackBar(SnackBar(
content: Text("This Account Not Exists"),
));
}).whenComplete((){
final directions = await GooglemapRepo().getDirection(
origin: LatLng(position.latitude, position.longitude),
destination: LatLng(lat, lng),
);
print(directions);
setState(() {
info12 = directions;
});
});