How can I keep user login when they restart the app?

55 views Asked by At

I watch freecodecamp tutorial: https://youtu.be/njLEDvoDjtk?t=7598

In this time stamp his code to keep use in

home: ref.watch(currentuserProvider).when(
          data: (data) {
            if (data != null) {
              return HOme_Viewer();
            } else {
              return signup();
            }
          },
          error: (error, stackTrace) => Text(error.toString()),
          loading: () {
            return CircularProgressIndicator.adaptive();
          }),

I want to make the same approach but with using go_router package, so I try:

 final app = ref.watch(currentuserProvider).value;
  return GoRouter(
    initialLocation: '/',
    routes: [
      GoRoute(
        path: signup.route,
        name: "Signup",
        builder: (BuildContext context, GoRouterState state) {
          return signup();
        },
        redirect: (context, state) {
          if (app != null) {
            return HOme_Viewer.route;
          }
          return null;
        },
      ),

But it did not work.

0

There are 0 answers