'Flutter Web: How to get query params from service worker?
Solution 1:[1]
I found a solution to use. in web/index.html, I've created a function:
<script type="application/javascript">
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
);
function getEmail() {
return params.email;
}
</script>
and in the main.dart file, I imported dart:js package
import 'dart:js' as js;
and I call it that I've created javascript function in web/index.html
String? email;
Future<void> getEmail() async {
setState(() {
email = js.context.callMethod('getEmail');
});
}
I added the codes above in case other people need it. thanks
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 | Serdar Polat |


