Reputation: 35
I am using gorouter in flutter to navigate. whenever i use context.push("/article/1234") it goes to proper page but if I put the link directly in browser I get a blank screen.
following is my code
GoRoute(
path: "/article/:id",
builder:(context,state) => ArticleScreen(id:state.params['id']),
),
if i use below code it works as expected but if i put the url in browser it shows a blank page
context.go("/article/1234");
Upvotes: 2
Views: 1228
Reputation: 1261
This issue is fixed and merged in the Flutter's master channel. Might get live in the future stable releases.
GitHub Issue to keep track of the problem.
Also, I could not find permanent fix for this but I found this pull request which actually gives a fix the problem.
You can also configure the main.dart.js
and flutter_service_worker.js
URLs in the index.html
file as described in this comment to something that matches your app:
_flutter.loader.loadEntrypoint({
entrypointUrl: "/YOUR_APP_BASE/main.dart.js",
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
serviceWorkerUrl: "/YOUR_APP_BASE/flutter_service_worker.js?v=",
},
That way the files will be requested from their "absolute" URL, rather than URLs relative to the ones specified by the PathStrategy.
(If your base URL is "/", you just need: /main.dart.js
and /flutter_service_worker.js?v=
)
Upvotes: 1