[Flutter/dart]Open a URL that requires encoding
Problem
Previously, I wrote an article that it is necessary to encode to open a URL containing Japanese.
However, re-encoding an already encoded URL will result in a different URL.
In other words, before processing to open the URL,
Does the URL require encoding?
Is it already encoded?
will have to be judged. This is a rather complicated process.
Situation
As a situation where the above problem occurs, there is a case opening the URL registered by the user in WebView.
There are often cases where Japanese websites include Japanese in the URL,
When you get the URL with shareExtent, you can receive the encoded one
When the user directly copies and pastes the browser URL, whether the copied URL is encoded or not depends on the browser specifications. In chrome and firefox it is encoded but in safari it is not
In such a case, it becomes a situation that you do not know whether the registered URL is encoded or not.
Solution
All you have to do is conv.
Uri _uri = await Uri.parse(url);
await launchUrl(_uri);
Recent Posts
See AllWhat want to do There is an operation that operates on two-dimensional arrays There are multiple targets to be processed In this case, I...
What want to do As stated in the title, I would like to define an array of function pointers. Specifically, for example, the third...
Phenomenon There is an array Check whether the index variable is within the size of the array, and access the element only if it is...
Comments