Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call onLoaded on Windows #96

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@

# Changelog

## 1.6.1

* Fixed: `onLoaded` not invoked on Windows
* Updated:
* permission_handler from 9.2.0 to 10.2.0 (#94)
* markdown from 4.0.1 to 6.0.1 (#89)
* webview_windows from 0.1.9 to 0.2.1 (#88)
* flutter_lints from 1.0.4 to 2.0.1 (#82)

## 1.6.0

* Adding windows platform
Expand Down
35 changes: 33 additions & 2 deletions lib/src/platforms/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WindowsWebView extends WebView {
}

class WindowsWebViewState extends WebViewState<WindowsWebView> {
final controller = wv.WebviewController();
final wv.WebviewController controller = wv.WebviewController();
bool isSuspended = false;

@override
Expand All @@ -39,7 +39,11 @@ class WindowsWebViewState extends WebViewState<WindowsWebView> {
}

Future<void> reload() async {
await controller.loadUrl(url);
await controller.loadUrl(url).then((value) {
if(widget.onLoaded != null){
widget.onLoaded!(EasyWebViewControllerWrapper._(controller));
}
});
}

Future<void> initPlatformState() async {
Expand All @@ -62,6 +66,8 @@ class WindowsWebViewState extends WebViewState<WindowsWebView> {
}
});

controller;

await controller.setBackgroundColor(options.backgroundColor);
await controller.setPopupWindowPolicy(options.popupWindowPolicy);
await reload();
Expand All @@ -84,6 +90,7 @@ class WindowsWebViewState extends WebViewState<WindowsWebView> {

@override
Widget builder(BuildContext context, Size size, String contents) {

return wv.Webview(
controller,
permissionRequested: (url, kind, isUserInitiated) => onPermissionRequest(
Expand Down Expand Up @@ -138,3 +145,27 @@ class WindowsWebViewState extends WebViewState<WindowsWebView> {
isSuspended = false;
}
}

class EasyWebViewControllerWrapper extends EasyWebViewControllerWrapperBase {

final wv.WebviewController _controller;

EasyWebViewControllerWrapper._(this._controller);

@override
Future<void> evaluateJSMobile(String js) {
throw UnsupportedError("the platform doesn't support this operation");
}

@override
Future<String> evaluateJSWithResMobile(String js) {
throw UnsupportedError("the platform doesn't support this operation");
}

@override
Object get nativeWrapper => _controller;

@override
void postMessageWeb(dynamic message, String targetOrigin) =>
throw UnsupportedError("the platform doesn't support this operation");
}
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: easy_web_view
description: A super simple webview for Flutter Web, Mobile and Desktop
version: 1.6.0
version: 1.6.1
homepage: https://github.com/rodydavis/easy_web_view
repository: https://github.com/rodydavis/plugins
maintainer: Rody Davis (@rodydavis)
Expand All @@ -14,16 +14,16 @@ dependencies:
flutter_widget_from_html: ^0.8.5
html2md: ^1.2.5
http: ^0.13.3
markdown: ^4.0.0
permission_handler: ^9.2.0
markdown: ^6.0.1
permission_handler: ^10.2.0
url_launcher: ^6.0.12
webview_flutter: ^3.0.2
webview_windows: ^0.1.6
webview_windows: ^0.2.1

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter_lints: ^2.0.1

flutter:
uses-material-design: true