2023-01-09 22:50:34 -05:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
|
2023-01-10 21:04:18 -05:00
|
|
|
import '../pages/pages.dart';
|
2023-01-09 22:50:34 -05:00
|
|
|
import 'router_notifier.dart';
|
|
|
|
|
|
|
|
final _key = GlobalKey<NavigatorState>(debugLabel: 'routerKey');
|
|
|
|
|
|
|
|
/// This simple provider caches our GoRouter.
|
|
|
|
final routerProvider = Provider.autoDispose<GoRouter>((ref) {
|
|
|
|
final notifier = ref.watch(routerNotifierProvider.notifier);
|
|
|
|
|
|
|
|
return GoRouter(
|
|
|
|
navigatorKey: _key,
|
|
|
|
refreshListenable: notifier,
|
|
|
|
debugLogDiagnostics: true,
|
2023-01-10 21:04:18 -05:00
|
|
|
initialLocation: IndexPage.path,
|
2023-01-09 22:50:34 -05:00
|
|
|
routes: notifier.routes,
|
|
|
|
redirect: notifier.redirect,
|
|
|
|
);
|
|
|
|
});
|