Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 9b08218

Browse files
committed
Support loading arbitrary files instead of only Flutter assets
1 parent 3151008 commit 9b08218

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

packages/webview_flutter/webview_flutter_platform_interface/lib/src/method_channel/webview_method_channel.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class MethodChannelWebViewPlatform implements WebViewPlatformController {
8080
}
8181

8282
@override
83-
Future<void> loadFlutterAsset(String assetName) async {
84-
assert(assetName != null);
85-
return _channel.invokeMethod<void>('loadFlutterAsset', assetName);
83+
Future<void> loadFile(String absoluteFilePath) async {
84+
assert(absoluteFilePath != null);
85+
return _channel.invokeMethod<void>('loadFile', absoluteFilePath);
8686
}
8787

8888
@override

packages/webview_flutter/webview_flutter_platform_interface/lib/src/platform_interface/webview_platform_controller.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ abstract class WebViewPlatformController {
2323
/// The `handler` parameter must not be null.
2424
WebViewPlatformController(WebViewPlatformCallbacksHandler handler);
2525

26-
/// Loads the Flutter asset specified in the pubspec.yaml file.
26+
/// Loads the file located on the specified [absoluteFilePath].
2727
///
28-
/// Throws an ArgumentError if [assetName] is not part of the specified assets
29-
/// in the pubspec.yaml file.
30-
Future<void> loadFlutterAsset(
31-
String assetName,
28+
/// Throws an ArgumentError if the [absoluteFilePath] does not exist.
29+
Future<void> loadFile(
30+
String absoluteFilePath,
3231
) {
3332
throw UnimplementedError(
3433
"WebView loadFlutterAsset is not implemented on the current platform");

packages/webview_flutter/webview_flutter_platform_interface/test/src/method_channel/webview_method_channel_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ void main() {
5555
log.clear();
5656
});
5757

58-
test('loadFlutterAsset', () async {
59-
await webViewPlatform.loadFlutterAsset(
60-
'folder/asset.html',
58+
test('loadFile', () async {
59+
await webViewPlatform.loadFile(
60+
'/folder/asset.html',
6161
);
6262

6363
expect(
6464
log,
6565
<Matcher>[
6666
isMethodCall(
67-
'loadFlutterAsset',
68-
arguments: 'folder/asset.html',
67+
'loadFile',
68+
arguments: '/folder/asset.html',
6969
),
7070
],
7171
);

0 commit comments

Comments
 (0)