open method

Future<void> open({
  1. required String url,
  2. bool javascriptEnabled = true,
  3. PresentationStyle presentationStyle = PresentationStyle.sheet,
  4. Size? size,
  5. String? userAgent,
  6. String modalTitle = '',
  7. String sheetCloseButtonTitle = 'Close',
})

Opens WebView with specified params

url - required param containing initial URL. Must not be null or empty

javascriptEnabled - enables or disables Javascript execution until next open call. Must not be null

presentationStyle - WebView window presentation style. Available styles are modal and sheet depending on which plugin calls respectively presentAsModalWindow or presentAsSheet from NSViewController. Must not be null

size - size of the WebView in pixels

userAgent - custom User Agent

modalTitle - title for window when using modal presentation style

sheetCloseButtonTitle - title for close button when using sheet presentation style

Implementation

Future<void> open({
  required String url,
  bool javascriptEnabled = true,
  PresentationStyle presentationStyle = PresentationStyle.sheet,
  Size? size,
  // Offset origin,
  String? userAgent,
  String modalTitle = '',
  String sheetCloseButtonTitle = 'Close',
}) async {
  assert(url.trim().isNotEmpty);

  await _channel.invokeMethod('open', {
    'url': url,
    'javascriptEnabled': javascriptEnabled,
    'presentationStyle': presentationStyle.index,
    'customSize': size != null,
    'width': size?.width,
    'height': size?.height,
    'userAgent': userAgent,
    'modalTitle': modalTitle,
    'sheetCloseButtonTitle': sheetCloseButtonTitle,
    // 'customOrigin': origin != null,
    // 'x': origin?.dx,
    // 'y': origin?.dy,
  });
}