-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter] Android implementation of loadFile
and loadHtmlString
methods
#4544
[webview_flutter] Android implementation of loadFile
and loadHtmlString
methods
#4544
Conversation
This commit adds the `loadData` and `loadDataWithBaseUrl` methods to the pigeon communication interface. Next step would be to include the implementation details on the Android (JAVA) side.
Adds the native Android implementation for the `loadData` and `loadDataWithBaseUrl` API methods.
Adds the Dart implementation of Android's WebView `loadData` and `loadDataWithBaseUrl` methods. Also fixed support for null parameters in the native Android implementation.
/// The [mimeType] parameter specifies the format of the data. If WebView | ||
/// can't handle the specified MIME type, it will download the data. If | ||
/// `null`, defaults to 'text/html'. | ||
Future<void> loadData(String data, String? mimeType, String? encoding) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I choose to make the mimeType
and encoding
parameters nullable positional parameters to match the original JAVA API as close as possible. Alternatively I could also make these optional named parameters which might make the Dart API a bit more user friendly. @bparrishMines, @stuartmorgan what would you prefer?
P.S. the same is true for the nullable parameters of the loadDataWithBaseUrl
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think optional named parameters should work fine here. I agree it makes the code more Darty without changing the method.
78852dd
to
7b63509
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I left just a few comments
...tter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewHostApiImpl.java
Show resolved
Hide resolved
/// The [mimeType] parameter specifies the format of the data. If WebView | ||
/// can't handle the specified MIME type, it will download the data. If | ||
/// `null`, defaults to 'text/html'. | ||
Future<void> loadData(String data, String? mimeType, String? encoding) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think optional named parameters should work fine here. I agree it makes the code more Darty without changing the method.
packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart
Outdated
Show resolved
Hide resolved
Hi @bparrishMines, thank you for the review. I have processed your feedback and would appreciate it if you could have another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…oadHtmlString` methods (flutter/plugins#4544)
Adds implementations of the
loadFile
andloadHtmlString
method channel calls for the webview_flutter_android package.The
loadFile
andloadHtmlString
methods have been added to the platform interface by PR #4446 and this PR will add the Android implementation.Related to issues:
NOTE: as per offline discussion with @stuartmorgan the loading of Flutter assets (assets registered within the pubspec.yaml) should be handled via the
loadFile
method and retrieve the path to the physical asset location the path_provider should be used (or something similar). At the moment the path_provider doesn't support returning the path to the physical location of Flutter assets there is however an issue (flutter/flutter#34026) to track this functionality.If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).