Skip to content

Add NavigationKey in GoRouter #109479

@DieGlueckswurst

Description

@DieGlueckswurst

Steps to Reproduce

I am using the go_router in my app and also the get package. The problem is that since I implemented the Go-Router I can no longer show the Get.snackbar. It is failing and throwing a null-error.

For the GoRouter to work I had to add the .router for my GetMaterialApp. And then navigationKey was no longer available:

This is my GetMaterialApp:

  child: GetMaterialApp.router(
    title: 'Wishlists',

    // navigationKey: Get.key, 
    // .router does not have a navigationKey so showSnackBar fails because the key is null


    routeInformationProvider: router.routeInformationProvider,
    routeInformationParser: router.routeInformationParser,
    routerDelegate: router.routerDelegate,
    translationsKeys: AppTranslation.translationsKeys,
    locale: locale,
    fallbackLocale: fallbackLocale,

  ),

This is the error:

Error: Unexpected null value.
at Object.throw_ [as throw] (http://localhost:51492/dart_sdk.js:5080:11)
at Object.nullCheck (http://localhost:51492/dart_sdk.js:5399:30)
at [_configureOverlay] (http://localhost:51492/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:2970:53)
at [_show] (http://localhost:51492/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:3113:30)

I feel like it has something to do with the key inside the GetMaterialApp, but I have no idea how to solve this.

Is this a known bug? What am I missing here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions