i'm new to flutter, i'm trying to display response from the server on my screen. I get from the server Orders history and trying to display it on History screen, how can u do this?
void getAllHistory() async {
http
.post(
Uri.parse(
'https://myurlblahblah'),
body: "{\"token\":\"admin_token\"}",
headers: headers)
.then((response) {
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
}).catchError((error) {
print("Error: $error");
});
}
}
I don't have experience with request to server, so i don't know how to display it anywhere except "print"
class HistoryScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(),
body: BodyLayout(),
);
}
AppBar buildAppBar() {
return AppBar(
automaticallyImplyLeading: false,
title: Row(
children: [
BackButton(),
SizedBox(width: 15),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Orders history",
style: TextStyle(fontSize: 16),
),
],
)
],
),
);
}
}
PS "BodyLayout" is just a list view, do i need to past my response code here? I want to get all orders history when i switch to "History Screen" I would really appreciate code example