loadFile method

  1. @override
Future<void> loadFile(
  1. String absoluteFilePath
)

See WebViewController.loadFile or WebViewPlatformController.loadFile.

Known bug (?)

The timing of when Future is resolved is different from Android/iOS. Immediately after this method is resolved, the new URL cannot yet be obtained with currentUrl.

TODO(Ino): Immediately reflect the new URL in currentUrl.

Implementation

@override
Future<void> loadFile(
  String absoluteFilePath,
) async {
  final int? webviewId = instanceManager.getInstanceId(this);
  if (webviewId == null) {
    throw 'Failed to get the webview instance';
  }
  final String url = absoluteFilePath.startsWith('file://')
      ? absoluteFilePath
      : 'file://$absoluteFilePath';
  await (await LinuxWebViewPlugin.channel)
      .invokeMethod('loadUrl', <String, dynamic>{
    'webviewId': webviewId,
    'url': url,
  });
}