2023-05-28 12:54:46 +00:00
|
|
|
import 'dart:developer';
|
|
|
|
|
2022-12-25 15:16:23 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
2023-05-28 12:54:46 +00:00
|
|
|
import 'package:http/http.dart' as http;
|
2022-12-25 15:16:23 +00:00
|
|
|
|
|
|
|
class LobbySelector extends StatelessWidget {
|
|
|
|
const LobbySelector({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-12-25 19:18:50 +00:00
|
|
|
return Scaffold(
|
|
|
|
body: TextButton(
|
2022-12-25 15:16:23 +00:00
|
|
|
onPressed: () {
|
2023-05-28 12:54:46 +00:00
|
|
|
var randomGameFuture = registerForRandomGame();
|
|
|
|
log(randomGameFuture.toString());
|
|
|
|
context.goNamed('prepareChessGame', extra: randomGameFuture);
|
2022-12-25 15:16:23 +00:00
|
|
|
},
|
|
|
|
child: const Text('Random lobby'),
|
2022-12-25 19:18:50 +00:00
|
|
|
),
|
2022-12-25 15:16:23 +00:00
|
|
|
);
|
|
|
|
}
|
2023-05-28 12:54:46 +00:00
|
|
|
|
|
|
|
Future<http.Response> registerForRandomGame() {
|
|
|
|
return http.get(Uri.parse('http://localhost:8080/api/random'));
|
|
|
|
}
|
2022-12-25 15:16:23 +00:00
|
|
|
}
|