mchess-client/lib/pages/lobby_selector.dart
2023-05-28 14:56:01 +02:00

28 lines
727 B
Dart

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart' as http;
class LobbySelector extends StatelessWidget {
const LobbySelector({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: TextButton(
onPressed: () {
var randomGameFuture = registerForRandomGame();
log(randomGameFuture.toString());
context.goNamed('prepareChessGame', extra: randomGameFuture);
},
child: const Text('Random lobby'),
),
);
}
Future<http.Response> registerForRandomGame() {
return http.get(Uri.parse('http://localhost:8080/api/random'));
}
}