mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
25 lines
663 B
Dart
25 lines
663 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
import '../pages/index.dart';
|
|
import 'router_notifier.dart';
|
|
|
|
part 'router.g.dart';
|
|
|
|
final _key = GlobalKey<NavigatorState>(debugLabel: 'routerKey');
|
|
|
|
/// This simple provider caches our GoRouter.
|
|
@riverpod
|
|
GoRouter router(RouterRef ref) {
|
|
final notifier = ref.watch(routerNotifierProvider.notifier);
|
|
return GoRouter(
|
|
navigatorKey: _key,
|
|
refreshListenable: notifier,
|
|
debugLogDiagnostics: true,
|
|
initialLocation: IndexPage.path,
|
|
routes: notifier.routes,
|
|
redirect: notifier.redirect,
|
|
);
|
|
}
|