Files
venir.dev 599b66417b Implemented some corrections / optimizations
To follow best practices is very important to me
2022-12-30 21:01:55 +01:00

27 lines
706 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';
import 'routes.dart';
part 'router.g.dart';
final _key = GlobalKey<NavigatorState>(debugLabel: 'routerKey');
/// This simple provider caches our GoRouter.
/// This provider will never rebuild by design.
@riverpod
GoRouter router(RouterRef ref) {
final notifier = ref.watch(routerNotifierProvider.notifier);
return GoRouter(
navigatorKey: _key,
refreshListenable: notifier,
debugLogDiagnostics: true,
initialLocation: SplashRoute.path,
routes: notifier.routes,
redirect: notifier.redirect,
);
}