run method Null safety

Future<void> run()

Runs the headless WebView.

Implementation

Future<void> run() async {
  if (_started) {
    return;
  }
  _started = true;
  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('id', () => id);
  args.putIfAbsent(
      'params',
      () => <String, dynamic>{
            'initialUrlRequest': (this.initialUrlRequest ??
                    URLRequest(url: Uri.parse("about:blank")))
                .toMap(),
            'initialFile': this.initialFile,
            'initialData': this.initialData?.toMap(),
            'initialOptions': this.initialOptions?.toMap() ?? {},
            'contextMenu': this.contextMenu?.toMap() ?? {},
            'windowId': this.windowId,
            'initialUserScripts':
                this.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
            'pullToRefreshOptions':
                this.pullToRefreshController?.options.toMap() ??
                    PullToRefreshOptions(enabled: false).toMap(),
            'initialSize': this.initialSize.toMap()
          });
  await _sharedChannel.invokeMethod('run', args);
  _running = true;
}