flutter-plugins icon indicating copy to clipboard operation
flutter-plugins copied to clipboard

[desktop_webview_window]: addOnUrlRequestCallback not triggered on SPA (e.g. React) client-side route changes

Open kunjaarogyatech opened this issue 5 months ago • 1 comments

Hi, thank you for this helpful plugin!

I'm using desktop_webview_window in my Flutter Linux app to embed a webview. The addOnUrlRequestCallback works fine for traditional full-page navigations, but it's not triggered when navigating within a Single Page Application (SPA) such as a React app that uses client-side routing (e.g. React Router or Next.js).

Steps to Reproduce:

  1. Load a React-based SPA (e.g. a local or deployed React app) in the webview.
  2. Use the app's navigation (e.g. Use navigate or clicking on a <Link> element to route to another page).
  3. Observe that addOnUrlRequestCallback is not called on these URL changes.

Expected Behavior:

  1. The callback should also be triggered when the URL changes due to client-side routing in SPAs, not just for full-page navigations.
  2. Alternatively, we could have a new dedicated callback specifically for detecting URL changes in SPA apps.

Actual Behavior: addOnUrlRequestCallback is only triggered for full page loads (e.g. window.location.href = '...') and not for history API-based routing (history.pushState, replaceState), which is commonly used in SPAs.

Environment: OS: Linux Flutter version: 3.29.2 Plugin version: ^0.2.3

kunjaarogyatech avatar Jun 27 '25 07:06 kunjaarogyatech

I'd like to work on this issue. Please assign it to me.

I’ll implement support for detecting SPA-style URL changes natively on the Linux GTK side and add a new callback/update callback through the method channel to notify Flutter about those changes.

Happy to contribute and open a PR for this enhancement.

kunjaarogyatech avatar Jun 27 '25 07:06 kunjaarogyatech