Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to redirect the app to a specific screen after submitting feedback #282

Closed
poojadev opened this issue Jun 7, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@poojadev
Copy link

poojadev commented Jun 7, 2023

Hello, we are using Wiredash in our application for gathering feedback. but facing one issue after submitting feedback, Wiredash always redirects it to the home page rather than redirecting to a specific page. Is there any solution? How can we redirect it to a specific screen after submitting feedback.
i.e., I'm submitting feedback from the profile page, but Wiredash always redirects it to the main home page.

@poojadev poojadev added the bug Something isn't working label Jun 7, 2023
@passsy
Copy link
Member

passsy commented Jun 7, 2023

Wiredash doesn't navigate at all and does not redirect to the home page.

It seems like you lose the application state at some point, resetting your Navigator and thus land on the home page. There could be a million reasons why it is happening.

One common mistake is to initialize some things in didChangeDependencies. Especially, high up in the widget tree, devs often expect didChangeDependencies to be called only once. But it is called again when wiredash opens/closes.

There is currently no callback when a user leaves the feedback flow. But is that actually what you want or do you only want to stay on the current page?

@poojadev
Copy link
Author

poojadev commented Jun 7, 2023

Yes I only want to stay on the current page like router.pop() and I'm using auto_route package for routing.

@passsy
Copy link
Member

passsy commented Jun 7, 2023

Assuming you copy-pasted the sample from the readme:

// assuing this is the root widget of your App                 
class App extends StatelessWidget {            
  // make sure you don't initiate your router                
  // inside of the build function.                
  final _appRouter = AppRouter();            
            
  @override            
  Widget build(BuildContext context){            
    return MaterialApp.router(            
      routerConfig: _appRouter.config(),         
    );            
  }            
}    

You will lose the state of the _appRouter whenever the App rebuilds. (That's what's happening when Wiredash opens/closes).

Make it a StatefulWidget instead, and save _appRouter in your state

@poojadev
Copy link
Author

poojadev commented Jun 8, 2023

  return Wiredash(
        options: WiredashOptionsData(
          localizationDelegate: const CustomWiredashTranslations(),
        ),
        projectId: '',
        secret: '',
        child: MaterialApp.router(
          routerConfig: _appRouter.config(
            navigatorObservers: () => [
              SentryNavigatorObserver(),
            ],
          ),

Hi we are already using StatefulWidgets and saving stated in _appRouter. Still when i submit feedback it re-builds and redirects to main page.

@passsy
Copy link
Member

passsy commented Jun 8, 2023

Then you have to figure out why Navigator gets disposed, or who's navigating to home. Try setting breakpoints and try to find the root cause.

You could also try playing around with global keys. Set one to Wiredash, one to MaterialApp.router and so on. It might fix it but that is not solving the root cause. You might run into other problems.

There's nothing I can help you with from here, sorry. The error is not reproducible in an example. It is a bug somewhere in your codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants