cocatenation et serialization json

This commit is contained in:
Valentin CZERYBA 2022-09-01 22:07:07 +02:00
parent b2f15acda8
commit 28c79a6ad2

View File

@ -54,7 +54,7 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
String listUser = "";
Future<void> _incrementCounter() async {
var url = Uri.parse("http://localhost:8083/api/token");
@ -86,6 +86,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
}
}
String former = "";
stderr.writeln("User ${user}");
stderr.writeln("Jwt ${jwt}");
stderr.writeln('Response status: ${response.statusCode}');
@ -97,13 +98,18 @@ class _MyHomePageState extends State<MyHomePage> {
stderr.writeln('Response Get status: ${responseGet.statusCode}');
stderr.writeln('Response Get body: ${responseGet.body}');
var json = jsonDecode(responseGet.body);
for (var user in json) {
former = "$former\n ${user['name']}";
}
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
listUser = former;
});
}
@ -145,7 +151,7 @@ class _MyHomePageState extends State<MyHomePage> {
'You have pushed the button this many times:',
),
Text(
'$_counter',
'$listUser',
style: Theme.of(context).textTheme.headline4,
),
],