work in progress
This commit is contained in:
parent
e3069a1eb8
commit
ce489bc86a
@ -136,7 +136,7 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
|||||||
|
|
||||||
if (access_token.isNotEmpty) {
|
if (access_token.isNotEmpty) {
|
||||||
print("Appel HTTP");
|
print("Appel HTTP");
|
||||||
var urlToken = Uri.parse("https://${globals.api}/token");
|
var urlToken = Uri.parse("${globals.api}/token");
|
||||||
|
|
||||||
var responseToken = await http.get(urlToken,
|
var responseToken = await http.get(urlToken,
|
||||||
headers: {HttpHeaders.cookieHeader: 'access_token: ${access_token}'});
|
headers: {HttpHeaders.cookieHeader: 'access_token: ${access_token}'});
|
||||||
|
@ -10,6 +10,8 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
|
|
||||||
import '../variable/globals.dart' as globals;
|
import '../variable/globals.dart' as globals;
|
||||||
|
|
||||||
|
import '../classes/events.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
@ -18,6 +20,7 @@ class MyApp extends StatelessWidget {
|
|||||||
const MyApp({Key? key}) : super(key: key);
|
const MyApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
// This widget is the root of your application.
|
// This widget is the root of your application.
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
@ -52,32 +55,39 @@ class ItemMenu extends StatefulWidget {
|
|||||||
// always marked "final".
|
// always marked "final".
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ItemMenu> createState() => _ItemMenuState();
|
State<ItemMenu> createState() => _ItemMenuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||||
String listUser = "";
|
String listUser = "";
|
||||||
|
String eventName = "";
|
||||||
|
|
||||||
Future<void> _incrementCounter() async {
|
Events? events;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
_getEventInfos();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _getEventInfos() async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
String former = "";
|
String former = "";
|
||||||
|
print("${accessToken}");
|
||||||
|
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
var urlGet = Uri.parse("${globals.api}/events");
|
var urlGet = Uri.parse("${globals.api}/events/${widget.title}");
|
||||||
|
|
||||||
var responseGet = await http.get(urlGet,
|
var responseGet = await http.get(urlGet,
|
||||||
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
|
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
|
||||||
stderr.writeln('Response Get status: ${responseGet.statusCode}');
|
stderr.writeln('Response Get status: ${responseGet.statusCode}');
|
||||||
if (responseGet.statusCode == 200) {
|
if (responseGet.statusCode == 200) {
|
||||||
stderr.writeln('Username : ${responseGet.body}');
|
stderr.writeln('Username : ${responseGet.body}');
|
||||||
var json = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
Events events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
||||||
for (var user in json) {
|
print(events.name);
|
||||||
stderr.writeln('name : ${user['name']}');
|
former = events.name!;
|
||||||
former = "$former\n ${user['name']} : ${user["place"]}";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
var text = "";
|
var text = "";
|
||||||
switch (responseGet.statusCode) {
|
switch (responseGet.statusCode) {
|
||||||
@ -129,7 +139,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
// so that the display can reflect the updated values. If we changed
|
// so that the display can reflect the updated values. If we changed
|
||||||
// _counter without calling setState(), then the build method would not be
|
// _counter without calling setState(), then the build method would not be
|
||||||
// called again, and so nothing would appear to happen.
|
// called again, and so nothing would appear to happen.
|
||||||
listUser = former;
|
eventName = former;
|
||||||
|
print(eventName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +158,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
// Here we take the value from the MyHomePage object that was created by
|
// Here we take the value from the MyHomePage object that was created by
|
||||||
// the App.build method, and use it to set our appbar title.
|
// the App.build method, and use it to set our appbar title.
|
||||||
title: Text(widget.title),
|
title: Text("eventName : ${eventName}"),
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
),
|
),
|
||||||
@ -198,11 +209,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
// This trailing comma makes auto-formatting nicer for build methods.
|
||||||
onPressed: _incrementCounter,
|
|
||||||
tooltip: 'Increment',
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user