I want to call decodeUrl(...)
and I was doing it as:
import "dart:uri";
main() {
decodeUrl("str");
}
But now with the latest Dart-SDK, it reports:
Do not know how to load 'dart:uri'
import 'dart:uri';
^
Seems it has been removed from the SDK. I searched a lot but still don't know where is it now. How to use the decodeUrl(...)
with latest SDK now?
The Uri class supports functions to encode and decode strings for use in URIs (which you might know as URLs). These functions control characters that are unique for URIs, such as & and =. This class also parses and exposes the components of a URI—host, port, scheme, and so on.
parse method Null safetyCreates a new Uri object by parsing a URI string. If start and end are provided, they must specify a valid substring of uri , and only the substring from start to end is parsed as a URI. If the uri string is not valid as a URI or URI reference, a FormatException is thrown.
According to this post to the Dart announcement list, dart:uri
has been replaced with the core Uri class.
Your code translates to:
main() {
decodeUrl("str");
}
Though it might be more instructive to write print(Uri.decodeFull("str%20here"));
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With