loadData method
Loads the given data into this WebView, using baseUrl as the base URL for the content.
mimeTypeparameter specifies the format of the data. The default value is"text/html".encodingparameter specifies the encoding of the data. The default value is"utf8".androidHistoryUrlparameter is the URL to use as the history entry. The default value isabout:blank. If non-null, this must be a valid URL. This parameter is used only on Android.iosAllowingReadAccessTo, used in combination withbaseUrl(using thefile://scheme), is an iOS-specific argument that 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.
Official Android API: https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)
Official iOS API:
Implementation
Future<void> loadData(
{required String data,
String mimeType = "text/html",
String encoding = "utf8",
Uri? baseUrl,
Uri? androidHistoryUrl,
Uri? iosAllowingReadAccessTo}) async {
assert(iosAllowingReadAccessTo == null ||
iosAllowingReadAccessTo.isScheme("file"));
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('data', () => data);
args.putIfAbsent('mimeType', () => mimeType);
args.putIfAbsent('encoding', () => encoding);
args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank");
args.putIfAbsent(
'historyUrl', () => androidHistoryUrl?.toString() ?? "about:blank");
args.putIfAbsent(
'allowingReadAccessTo', () => iosAllowingReadAccessTo?.toString());
await _channel.invokeMethod('loadData', args);
}