mchess-client/lib/utils/chess_router.dart
2023-12-27 15:46:15 +01:00

49 lines
1.2 KiB
Dart

import 'package:go_router/go_router.dart';
import 'package:mchess/pages/chess_game.dart';
import 'package:mchess/pages/lobby_selector.dart';
import 'package:mchess/pages/host_game.dart';
class ChessAppRouter {
static final ChessAppRouter _instance = ChessAppRouter._internal();
ChessAppRouter._internal();
static ChessAppRouter getInstance() {
return _instance;
}
final router = GoRouter(
debugLogDiagnostics: true,
routes: [
GoRoute(
path: '/',
name: 'lobbySelector',
builder: (context, state) {
return const LobbySelector();
},
routes: [
GoRoute(
path: 'host',
name: 'host',
builder: (context, state) {
return const HostGameWidget();
}),
GoRoute(
path: 'game',
name: 'game',
builder: (context, state) {
var args = state.extra as ChessGameArguments;
return ChessGame(
lobbyID: args.lobbyID,
playerID: args.playerID,
passphrase: args.passphrase,
);
},
)
],
),
],
);
}