loadData method
- required String data,
- String mimeType = "text/html",
- String encoding = "utf8",
- WebUri? baseUrl,
- @Deprecated('Use historyUrl instead') Uri? androidHistoryUrl,
- WebUri? historyUrl,
- @Deprecated('Use allowingReadAccessTo instead') Uri? iosAllowingReadAccessTo,
- WebUri? allowingReadAccessTo,
Loads the given data into this WebView, using baseUrl as the base URL for the content.
mimeTypeargument specifies the format of the data. The default value is"text/html".encodingargument specifies the encoding of the data. The default value is"utf8".historyUrlrepresents the URL to use as the history entry. The default value isabout:blank. If non-null, this must be a valid URL.allowingReadAccessTo, used in combination withbaseUrl(using thefile://scheme), it represents the URL from which to read the web content. ThisbaseUrlmust be a file-based URL (using thefile://scheme). Specify the same value as thebaseUrlparameter to prevent WebView from reading any other content. Specify a directory to give WebView permission to read additional files in the specified directory.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebView.loadDataWithBaseURL)
- iOS WKWebView (Official API - WKWebView.loadHTMLString):
- macOS WKWebView (Official API - WKWebView.loadHTMLString):
- Web <iframe> but requires same origin
- Windows WebView2 (Official API - ICoreWebView2.NavigateToString)
- Linux WPE WebKit (Official API - webkit_web_view_load_html)
Parameters - Officially Supported Platforms/Implementations:
data: all platformsmimeType:- Android WebView
- iOS WKWebView
- macOS WKWebView
- Web <iframe> but requires same origin
encoding:- Android WebView
- iOS WKWebView
- macOS WKWebView
baseUrl:- Android WebView
- iOS WKWebView
- macOS WKWebView
historyUrl:- Android WebView
allowingReadAccessTo:- iOS WKWebView
- macOS WKWebView
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
Future<void> loadData({
required String data,
String mimeType = "text/html",
String encoding = "utf8",
WebUri? baseUrl,
@Deprecated('Use historyUrl instead') Uri? androidHistoryUrl,
WebUri? historyUrl,
@Deprecated('Use allowingReadAccessTo instead')
Uri? iosAllowingReadAccessTo,
WebUri? allowingReadAccessTo,
}) => platform.loadData(
data: data,
mimeType: mimeType,
encoding: encoding,
baseUrl: baseUrl,
androidHistoryUrl: androidHistoryUrl,
historyUrl: historyUrl,
iosAllowingReadAccessTo: iosAllowingReadAccessTo,
allowingReadAccessTo: allowingReadAccessTo,
);