flutter_deck icon indicating copy to clipboard operation
flutter_deck copied to clipboard

fix: GoException: no routes for location: /presentation

Open nietsmmar opened this issue 7 months ago • 10 comments

Description

Since updating to version 0.19.0 I get this error when starting a presentation (meaning showing FlutterDeckApp widget):

GoException: no routes for location: /presentation

where /presentation is my route in which I build the FlutterDeckApp widget. So somehow the GoRouter from the FlutterDeckApp wants to suddenly open the route of my outer Routing. In version 0.18.0 all still worked fine. There it opened the presentation, showing the /presentationroute for a splitsecond and then showing /slide-1. I thought it might be because of the change to have initial Routes. I tried wrapping all my slides with FlutterDeckSlide.blank().withSlideConfiguration() and gave it a named route but this also did not fix it.

Steps To Reproduce

I tried to reproduce it in my minimal example that I've built for another issue and first could not. But then I realized that this only happens if there is some time going by being in the /presentation route before showing the FlutterDeckApp widget. This is happening in my case as I am awaiting the slides first before starting the DeckApp.

Here is a reproducible example: https://github.com/nietsmmar/flutter_deck_routing_problem

Expected Behavior

Presentation shows slides.

Screenshots

Image

nietsmmar avatar May 27 '25 10:05 nietsmmar

Apparently this error only occurs on platform: web. I have built it for linux and there it works fine.

nietsmmar avatar Jun 21 '25 12:06 nietsmmar

@nietsmmar Thanks for the input. I will keep this in mind. Just wondering, what difference does it make for Web, though 🤔

mkobuolys avatar Jun 22 '25 19:06 mkobuolys

That is what I wondered too! I am curious if it just has to do with the upgrade of the go_router version.

nietsmmar avatar Jun 23 '25 09:06 nietsmmar

@mkobuolys I did some investigation and this commit brings the regression: https://github.com/mkobuolys/flutter_deck/commit/935f3c0e076a9b6a3118952917d4584f7b9635e3

The problem is here in the flutter_deck_router.dart

if (!kIsWeb) return initialRoute;

  final fragment = Uri.base.fragment;

  return fragment.isNotEmpty ? Uri.parse(fragment).path : initialRoute;

That is also why it only happens on web. Uri.parse(fragment).path returns /presentation in my case.

Why is this even handled differently on web? Why is it returning the current fragment path there?

nietsmmar avatar Jun 23 '25 11:06 nietsmmar

I need to verify this, but having an initial route on Web makes zero sense - if you enter a specific route in the browser, that's the initial route you want to hit.

mkobuolys avatar Jun 23 '25 12:06 mkobuolys

@mkobuolys For me that makes a lot of sense. In my usecase you can click a start presentation- Button which will route to my /presentation route. There I am showing the FlutterDeckApp Widget to show my presentation in Web. But I want to have buttons on my page to be able to start the Presentation from specific slides. That is why I created the feature request for the initial route. I thought that the FlutterDeckApp Widget would then handle to show the presentation starting from this initial route.

Do you mean I should somehow route to it myself? But why having the initialRoute feature then?

if you enter a specific route in the browser, that's the initial route you want to hit.

This is a broken anyways when not using this package as standalone. In my reproducible Example, this is the path from second slide: http://localhost:42841/#/slide-2. But when I just call this URL in my browser, it will always break because the go_router from the outer app does not know this route. I just accepted that this does not work for the moment, because this is really tough to fix.

But I also did not fully understand the approach of the initialRoute implementation. What should one set in the route value in FlutterDeckSlideConfiguration? Whatever I set there my app crashes because the route does not exist. Why do I have to set a route name?

nietsmmar avatar Jun 23 '25 13:06 nietsmmar

@mkobuolys I can't upgrade since version 0.18.0 because of this as this fully breaks the package when using it in web in a not stand-alone mode (Having a GoRouter in the main app around it).

Because of the whole routing-problem (in web) when using it not as stand-alone there is the need to be able to set an initial route in web too.

nietsmmar avatar Jul 29 '25 09:07 nietsmmar

@mkobuolys Is there any plan to make this package work again when it is being used inside another app (GoRouter config)?

I think about forking it to make it work again.

nietsmmar avatar Sep 29 '25 10:09 nietsmmar

@nietsmmar Hey, it's hard to tell. GoRouter is pretty deeply integrated into the framework (how the whole navigation tree is built, slide pages having their routes, etc.), thus I am curious on how to solve it without rebuilding the whole routing layer. If you have any specific solution in mind - let me know. Maybe that could be an actual fix/improvement rather than another fork of the framework.

mkobuolys avatar Sep 29 '25 10:09 mkobuolys

@mkobuolys I had routing issues before but I could at least still make it work. Although the path in the browser-bar is confusing and wrong sometimes (not working to reload with it). But it was good enough for me to still use it.

The changes in this commit make it impossible for me to even start a presentation anymore. And hence the old version of this framework depends on an old go_router version it stops my whole app from upgrading dependencies. This is what pushes me to fix this urgently.

I couldn't come up with a solution completely fixing the Routing issue yet. It is super complicated. I have my Presentation-Route where I start the presentation. Your Framework will change the path from /#/presentation to /#/slide-1. On my slides I want to show interactive parts of my whole app that can push/pop pages themselves. So I wrapped them in an own Router with a ShellRoute. When I push pages in this shell on the slides, it also changes the path from /#/slide-1 to /#/myInternalRouteName. So the paths in the browser-bar are a complete mess because the routes don't know that they are nested. (but besides the shown paths, it actually works) But I have no idea how to fix this as I use type-safe routes and the paths for my routes would change according to where they are pushed. (from my outer app / from widgets on slides in the presentation-router)

If I would have a fix in mind I would try to contribute as an actual fix/improvement. But right now I am stuck. So my only chance to unblock my whole app from upgrading dependencies is to fork this framework and 'fix' return fragment.isNotEmpty ? Uri.parse(fragment).path : initialRoute; to just return initialRoute. (besides that I have the problem that I want to fix (or built my own) presenter-view, as this is also broken because of navigation issues.)

nietsmmar avatar Sep 29 '25 11:09 nietsmmar