[英]How to specify the encoding for a dart Uri in a Flutter project
我正在嘗試使用webview_flutter插件在應用程序中顯示一些靜態 html。
body: WebView(
initialUrl: Uri.dataFromString(
htmlString,
mimeType: 'text/html',
encoding: Encoding('utf-8')
).toString(),
),
我收到一個關於無效字符錯誤的錯誤,我認為這是因為 Uri 默認為 ASCII。 我正在嘗試將字符編碼設置為 UTF-8,但我不知道該怎么做。 Encoding('utf-8')
顯然不對。
如何設置編碼?
顫振中的安全 URL 編碼
前任。
String url = 'http://example.org/';
String postDataKey = "requestParam="
String postData = 'hdfhghdf+fdfbjdfjjndf'
在獲取請求的情況下:
Uri.encodeComponent(url+postDataKey+postData);
在 Post Data Request 的情況下使用flutter_inappwebview庫
var data = postDataKey + Uri.encodeComponent(postData);
webViewController.postUrl(url: Uri.parse(url), postData: utf8.encode(data));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.