veilidchat/lib/router/router.dart

24 lines
622 B
Dart
Raw Normal View History

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';
import 'router_notifier.dart';
2023-07-23 23:13:21 -04:00
part 'router.g.dart';
2023-01-09 22:50:34 -05:00
final _key = GlobalKey<NavigatorState>(debugLabel: 'routerKey');
/// This simple provider caches our GoRouter.
2023-07-23 23:13:21 -04:00
@riverpod
GoRouter router(RouterRef ref) {
2023-01-09 22:50:34 -05:00
final notifier = ref.watch(routerNotifierProvider.notifier);
return GoRouter(
navigatorKey: _key,
refreshListenable: notifier,
debugLogDiagnostics: true,
2023-08-17 18:10:24 -04:00
initialLocation: '/',
2023-01-09 22:50:34 -05:00
routes: notifier.routes,
redirect: notifier.redirect,
);
2023-07-23 23:13:21 -04:00
}