0

So basically I have a QR code generator in the app, I already implemented a feature generating it with url, such as domain.com/userid?=111. So, now I want QR code scanner to scan it and get only the id part of the user out of it, like it scanned the url example provided above, and then I just want to get '111' part to process. How can I implement it?

3
  • Shouldn't your url be domain.com?userid=111 instead of domain.com/userid?=111 Commented Jun 24, 2020 at 12:38
  • @JideGuru, no it should be domain.com/?userid=111, read more here: stackoverflow.com/a/1617074/1204153 Commented Jun 24, 2020 at 14:53
  • Ignore my comment, both should work and I don't want to start a debate about it like on that thread :) Either way, we can both agree OP's URI is wrong. Commented Jun 24, 2020 at 14:55

2 Answers 2

2

Use Uri queryParametersAll:

Uri url = Uri.parse('https://www.example.com/?userid=111');
print(url.queryParametersAll['userid'][0]);
Sign up to request clarification or add additional context in comments.

Comments

0

You can use substring method to get the part of it.

// Dart 2.6.1 

main() {
  String str = "domain.com/userid?=111";
  print(str.substring(str.indexOf("=")+1));
}

Comments

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.