Make ChessAppRouter a class.
This commit is contained in:
parent
d1ba004ebb
commit
330aeed476
@ -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',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,15 +2,25 @@ 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 {
|
||||||
routes: [
|
static final ChessAppRouter _instance = ChessAppRouter._internal();
|
||||||
GoRoute(
|
|
||||||
path: '/',
|
ChessAppRouter._internal();
|
||||||
builder: (context, state) => const LobbySelector(),
|
|
||||||
),
|
static ChessAppRouter getInstance() {
|
||||||
GoRoute(
|
return _instance;
|
||||||
path: '/play',
|
}
|
||||||
builder: (context, state) => const ChessGame(),
|
|
||||||
)
|
final router = GoRouter(
|
||||||
],
|
routes: [
|
||||||
);
|
GoRoute(
|
||||||
|
path: '/',
|
||||||
|
builder: (context, state) => const LobbySelector(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/play',
|
||||||
|
builder: (context, state) => const ChessGame(),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user