loadFlutterAsset method
See WebViewController.loadFlutterAsset
or WebViewPlatformController.loadFlutterAsset
.
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> loadFlutterAsset(
String key,
) async {
final int? webviewId = instanceManager.getInstanceId(this);
if (webviewId == null) {
throw 'Failed to get the webview instance';
}
final String assetUri = "file://" +
p.dirname(Platform.resolvedExecutable) +
"/data/flutter_assets/" +
key;
await (await LinuxWebViewPlugin.channel)
.invokeMethod('loadUrl', <String, dynamic>{
'webviewId': webviewId,
'url': assetUri,
});
}