loadData method

Future<void> loadData({
  1. required String data,
  2. String mimeType = "text/html",
  3. String encoding = "utf8",
  4. WebUri? baseUrl,
  5. @Deprecated('Use historyUrl instead') Uri? androidHistoryUrl,
  6. WebUri? historyUrl,
  7. @Deprecated('Use allowingReadAccessTo instead') Uri? iosAllowingReadAccessTo,
  8. WebUri? allowingReadAccessTo,
})

Loads the given data into this WebView, using baseUrl as the base URL for the content.

  • mimeType argument specifies the format of the data. The default value is "text/html".
  • encoding argument specifies the encoding of the data. The default value is "utf8". NOTE: not used on Web.
  • historyUrl is an Android-specific argument that represents the URL to use as the history entry. The default value is about:blank. If non-null, this must be a valid URL. NOTE: not used on Web.
  • allowingReadAccessTo, used in combination with baseUrl (using the file:// scheme), it represents the URL from which to read the web content. This baseUrl must be a file-based URL (using the file:// scheme). Specify the same value as the baseUrl parameter to prevent WebView from reading any other content. Specify a directory to give WebView permission to read additional files in the specified directory. NOTE: available only on iOS and MacOS.

NOTE for Windows: only the data parameter is used.

Officially Supported Platforms/Implementations:

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);