skip to Main Content

With flutter go router is it possible to disable the error page? Because I want the error to show in a snackbar instead. I tried doing it in the redirect but the error in the redirect seems empty when for example you route to a page that does not exist.

2

Answers


  1. Use try-catch block.

    try { // your code... } catch(e) { final snackBar = SnackBar(content: Text('Error ${e}'),);}

    Login or Signup to reply.
  2. Set a MyErrorPageScreen Widget and then inside MaterialApp.router -> routerConfig, set

         errorBuilder: (context, state) => MyErrorPageScreen()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search