open method

Future<void> open({
  1. required Uri url,
  2. ChromeSafariBrowserClassOptions? options,
})

Opens the ChromeSafariBrowser instance with an url.

url: The url to load. On iOS, the url must use the http or https scheme.

options: Options for the ChromeSafariBrowser.

Implementation

Future<void> open(
    {required Uri url, ChromeSafariBrowserClassOptions? options}) async {
  assert(url.toString().isNotEmpty);
  this.throwIsAlreadyOpened(message: 'Cannot open $url!');
  if (!kIsWeb && defaultTargetPlatform == TargetPlatform.iOS) {
    assert(['http', 'https'].contains(url.scheme),
        'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
  }

  List<Map<String, dynamic>> menuItemList = [];
  _menuItems.forEach((key, value) {
    menuItemList.add(value.toMap());
  });

  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('id', () => id);
  args.putIfAbsent('url', () => url.toString());
  args.putIfAbsent('options', () => options?.toMap() ?? {});
  args.putIfAbsent('actionButton', () => _actionButton?.toMap());
  args.putIfAbsent('menuItemList', () => menuItemList);
  await _sharedChannel.invokeMethod('open', args);
  this._isOpened = true;
}