Created project base structure, state management, router and login
This commit is contained in:
23
lib/providers/router_provider.dart
Normal file
23
lib/providers/router_provider.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:my_linkding/providers/api_client_provider.dart';
|
||||
import 'package:my_linkding/router/paths.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:my_linkding/router/routes.dart';
|
||||
|
||||
part 'router_provider.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
GoRouter router(RouterRef ref) {
|
||||
return GoRouter(
|
||||
redirect: (context, state) {
|
||||
if (ref.watch(apiClientProviderProvider) == null) {
|
||||
return RoutesPaths.connect;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
initialLocation: RoutesPaths.links,
|
||||
routes: appRoutes,
|
||||
navigatorKey: rootNavigatorKey,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user