1

My Use Case:

Users in my app can create lists of items. I want the users to be able to share a link to one of their lists.

I want individuals who click the shared link to see the list of items in a web browser and not need the app installed.

I originally thought Dynamic linking was what I was looking for. But as I have done more research I don't think I need dynamic linking to just read info from a link and the navigate to the right view in the web app.

My Attempt: onGenerateRoute

Doing some research I stumbled onto this Stack Overflow Question: How can a named route have URL parameters in flutter web?

After reading that I tried this in my own code:

routes: appRoutes,
        onGenerateRoute: (settings) {
          if (settings.name == "/pack") {
            //in your example: settings.name = "/post?id=123"

            final settingsUri = Uri.parse(settings.name!);
            //settingsUri.queryParameters is a map of all the query keys and values
            final postID = settingsUri.queryParameters['id'];
            print(postID); 

            Navigator.pushNamed(context, '/home');
          }
        },

I wanted to see if I could just print the id passed in https://myApp.app/pack?id=100

Unfortunately, I can't even get to that point to test my code above. I depleted my web app to my domain and if I go to any address other than https://myApp.app then I get a 404 error. Anything after the main URL like https://myApp.app/anything will go to a 404.

I have a hunch I need to edit my firebase.json. Right now it's set up for dynamic linking with /p but not sure what I need to fix here or someplace else to have the above code execute and not route to a 404 error page.

firebase.json

{
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "appAssociation": "AUTO",
    "rewrites": [
      {
        "source": "/p/**",
        "dynamicLinks": true
      }
    ]
  }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.