'How to create a variable <username> and insert it in website url like noob.com/<username> hosted on firebase?

I am developing a website using flutter and want to create a link for the website something like noob.com/username for a social profile of the user where username is the variable.

How to create this variable username which I can embed in URL and use to extract user info from cloud firestore?

I would highly appreciate a demo example if available anywhere built on flutter.

firebase.json file:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/username",
        "function": "username",
        "dynamicLinks": true
      }
    ]
  },
  "storage": {
    "rules": "storage.rules"
  }

    }


Solution 1:[1]

after 3 hours of research finally, I got an answer. Actually, there is no need to declare variables inside the URL nor does it makes any sense.

What you can do instead is extract the username through the current URL by running query (in flutter) :

final String _username = window.location.href.split('/')[3];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1