veilidchat/lib/router/router.dart
Christien Rioux 4ddfbe7746 cleanup
2023-09-21 21:00:58 -04:00

24 lines
622 B
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:riverpod_annotation/riverpod_annotation.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: '/',
routes: notifier.routes,
redirect: notifier.redirect,
);
}