Skip to content

Instantly share code, notes, and snippets.

@dhruvilp
Created July 3, 2021 00:42
Show Gist options
  • Select an option

  • Save dhruvilp/1edea99ed9a0c12779a8194b848a710d to your computer and use it in GitHub Desktop.

Select an option

Save dhruvilp/1edea99ed9a0c12779a8194b848a710d to your computer and use it in GitHub Desktop.
Get Current URL Query Parameters, Host Info, etc
import 'dart:html';
void main() {
// Uri uri = Uri.parse('https://www.example.com:3000/fruit?q=yellow');
Uri uri = Uri.parse(window.location.href);
print('Authority: '+uri.authority);
print('Fragment: '+uri.fragment);
print('Host: '+uri.host);
print('Origin: '+uri.origin);
print('Path: '+uri.path);
print('Query: '+uri.query);
print('Query Params: '+uri.queryParameters.toString());
print('Scheme: '+uri.scheme);
print('Port: '+uri.port.toString());
print('Path Segments: '+uri.pathSegments.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment