lucavenir / go_router_riverpod

An example on how to use Riverpod + GoRouter
460 stars 68 forks source link

Using the Global Key for firebase example #6

Closed hdbookie closed 1 year ago

hdbookie commented 1 year ago

Hey mate, love the project. It's working flawlessly for my work. I do have one question about it through, and not necessarily a bug report. How does one call the Global Key to navigate?? I'm creating a web app and I want to have simple navigation tabs in the app bar that take the user to the specified page. For example

return AppBar(
      title: TextButton(
        onPressed: isUserSignedIn
            ? () => key.currentState!.pushNamed('/dashboard')
            : () {
                key.currentState!.pushNamed('/preloginhome');
              },
        child: Text(
          'home',

          ),
        ),
      ),

will give me an errorNavigator.onGenerateRoute was null, but the route named "/preloginhome" was referenced. How can we access the routes we put in the routerProvider globally?

lucavenir commented 1 year ago

Hey there! I just pushed a new version of the example to address this and other problems

Having feed back would be great

Thank you for the time you've spent on this repo