mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2026-02-05 03:32:18 +00:00
init
This commit is contained in:
41
lib/router/app_router.dart
Normal file
41
lib/router/app_router.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:friflex_starter/features/debug/debug_routes.dart';
|
||||
import 'package:friflex_starter/features/debug/i_debug_service.dart';
|
||||
import 'package:friflex_starter/features/main/presentation/main_routes.dart';
|
||||
import 'package:friflex_starter/features/root/root_screen.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
/// Класс, реализующий роутер приложения и все поля классов
|
||||
class AppRouter {
|
||||
/// Конструктор для инициализации роутера
|
||||
const AppRouter();
|
||||
|
||||
/// Ключ для доступа к корневому навигатору приложения
|
||||
static final rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
/// Начальный роут приложения
|
||||
static String get initialLocation => '/main';
|
||||
|
||||
/// Метод для создания экземпляра GoRouter
|
||||
static GoRouter createRouter(IDebugService debugService) {
|
||||
return GoRouter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
debugLogDiagnostics: true,
|
||||
initialLocation: initialLocation,
|
||||
observers: [
|
||||
debugService.createRouterObserver(),
|
||||
],
|
||||
routes: [
|
||||
StatefulShellRoute.indexedStack(
|
||||
parentNavigatorKey: rootNavigatorKey,
|
||||
builder: (context, state, navigationShell) =>
|
||||
RootScreen(navigationShell: navigationShell),
|
||||
branches: [
|
||||
MainRoutes.buildShellBranch(),
|
||||
DebugRoutes.buildShellBranch(),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user