Make ChessAppRouter a class.

This commit is contained in:
Marco 2022-12-25 20:30:42 +01:00
parent d1ba004ebb
commit 330aeed476
2 changed files with 26 additions and 14 deletions

View File

@ -14,8 +14,10 @@ class ChessApp extends StatelessWidget {
child: BlocProvider( child: BlocProvider(
create: (_) => ChessBloc.getInstance(), create: (_) => ChessBloc.getInstance(),
child: MaterialApp.router( child: MaterialApp.router(
theme: ThemeData.dark(useMaterial3: true), theme: ThemeData.dark(
routerConfig: router, useMaterial3: true,
),
routerConfig: ChessAppRouter.getInstance().router,
title: 'mChess v0.1.1337', title: 'mChess v0.1.1337',
), ),
), ),

View File

@ -2,7 +2,16 @@ import 'package:go_router/go_router.dart';
import 'package:mchess/pages/chess_game.dart'; import 'package:mchess/pages/chess_game.dart';
import 'package:mchess/pages/lobby_selector.dart'; import 'package:mchess/pages/lobby_selector.dart';
final router = GoRouter( class ChessAppRouter {
static final ChessAppRouter _instance = ChessAppRouter._internal();
ChessAppRouter._internal();
static ChessAppRouter getInstance() {
return _instance;
}
final router = GoRouter(
routes: [ routes: [
GoRoute( GoRoute(
path: '/', path: '/',
@ -13,4 +22,5 @@ final router = GoRouter(
builder: (context, state) => const ChessGame(), builder: (context, state) => const ChessGame(),
) )
], ],
); );
}