openUrlRequest method Null safety

Future<void> openUrlRequest(
  1. {required URLRequest urlRequest,
  2. InAppBrowserClassOptions? options}
)

Opens the InAppBrowser instance with an urlRequest.

urlRequest: The urlRequest to load.

options: Options for the InAppBrowser.

Implementation

Future<void> openUrlRequest(
    {required URLRequest urlRequest,
    InAppBrowserClassOptions? options}) async {
  this.throwIfAlreadyOpened(message: 'Cannot open $urlRequest!');
  assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);

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