Skip to content

Commit f8e9c32

Browse files
committed
Expose loadFile and loadHtmlString.
Adds implementation to the `WebViewController` class to expose the `WebViewPlatformController.loadFile` and `WebViewPlatformController.loadHtmlString` methods.
1 parent 2c40c34 commit f8e9c32

File tree

1 file changed

+29
-0
lines changed
  • packages/webview_flutter/webview_flutter/lib/src

1 file changed

+29
-0
lines changed

packages/webview_flutter/webview_flutter/lib/src/webview.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,35 @@ class WebViewController {
495495

496496
WebView _widget;
497497

498+
/// Loads the file located on the specified [absoluteFilePath].
499+
///
500+
/// The [absoluteFilePath] parameter should contain the absolute path to the
501+
/// file as it is stored on the device. For example:
502+
/// `/Users/username/Documents/www/index.html`.
503+
///
504+
/// Throws an ArgumentError if the [absoluteFilePath] does not exist.
505+
Future<void> loadFile(
506+
String absoluteFilePath,
507+
) {
508+
assert(absoluteFilePath.isNotEmpty);
509+
return _webViewPlatformController.loadFile(absoluteFilePath);
510+
}
511+
512+
/// Loads the supplied HTML string.
513+
///
514+
/// The [baseUrl] parameter is used when resolving relative URLs within the
515+
/// HTML string.
516+
Future<void> loadHtmlString(
517+
String html, {
518+
String? baseUrl,
519+
}) {
520+
assert(html.isNotEmpty);
521+
return _webViewPlatformController.loadHtmlString(
522+
html,
523+
baseUrl: baseUrl,
524+
);
525+
}
526+
498527
/// Loads the specified URL.
499528
///
500529
/// If `headers` is not null and the URL is an HTTP URL, the key value paris in `headers` will

0 commit comments

Comments
 (0)