openData method

Future<void> openData({
  1. required String data,
  2. String mimeType = "text/html",
  3. String encoding = "utf8",
  4. Uri? baseUrl,
  5. Uri? androidHistoryUrl,
  6. InAppBrowserClassOptions? options,
})
inherited

Opens the InAppBrowser instance with data as a content, using baseUrl as the base URL for it.

The mimeType parameter specifies the format of the data. The default value is "text/html".

The encoding parameter specifies the encoding of the data. The default value is "utf8".

The androidHistoryUrl parameter is the URL to use as the history entry. The default value is about:blank. If non-null, this must be a valid URL. This parameter is used only on Android.

The options parameter specifies the options for the InAppBrowser.

Implementation

Future<void> openData(
    {required String data,
    String mimeType = "text/html",
    String encoding = "utf8",
    Uri? baseUrl,
    Uri? androidHistoryUrl,
    InAppBrowserClassOptions? options}) async {
  this.throwIfAlreadyOpened(message: 'Cannot open data!');

  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('id', () => id);
  args.putIfAbsent('options',
      () => options?.toMap() ?? InAppBrowserClassOptions().toMap());
  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('contextMenu', () => contextMenu?.toMap() ?? {});
  args.putIfAbsent('windowId', () => windowId);
  args.putIfAbsent('implementation', () => implementation.toValue());
  args.putIfAbsent('initialUserScripts',
      () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
  args.putIfAbsent(
      'pullToRefreshOptions',
      () =>
          pullToRefreshController?.options.toMap() ??
          PullToRefreshOptions(enabled: false).toMap());
  await _sharedChannel.invokeMethod('open', args);
}