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

Missing a way to change the dimension of rect #22

Closed
csbenjamin opened this issue Dec 25, 2017 · 3 comments
Closed

Missing a way to change the dimension of rect #22

csbenjamin opened this issue Dec 25, 2017 · 3 comments

Comments

@csbenjamin
Copy link

If I lunch the webview in a rect in non fullscreen mode, how do I change the rect dimension without reload the page in webview? I want to do this when the user rotate the screen.

@csbenjamin
Copy link
Author

csbenjamin commented Dec 26, 2017

I thought to put something like

private void resize(MethodCall call, final MethodChannel.Result result) {
    if (webViewManager != null) {
        
        Map<String, Number> rc = call.argument("rect");
        if (rc != null) {
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                    dp2px(activity, rc.get("width").intValue()), dp2px(activity, rc.get("height").intValue()));
            params.setMargins(dp2px(activity, rc.get("left").intValue()), dp2px(activity, rc.get("top").intValue()),
                    0, 0);
            
            activity.setContentView(webViewManager.webView, params);
        }
    }
}

in FlutterWebviewPlugin.java file and

Future<Null> resize(Rect rect) async{
  await _channel.invokeMethod('resize', {"rect":{
      "left": rect.left,
      "top": rect.top,
      "width": rect.width,
      "height": rect.height
    }});
}

in flutter_webview_plugin.dart file. But only this is not working. The first time I rotate the phone the build funcion of the widget is called and there I call the resize method, and it works as expected, but after that, it seems the webview lost the connection with the dart app, I mean, the build function doesn't execute anymore if I rotate the phone again and the onUrlChanged stream is not fired anymore if the url changes in the webview. What am I missing here? I never developed for android before, and it is my first try with java.

@lejard-h
Copy link
Collaborator

lejard-h commented Jan 7, 2018

yes we need something like that, I need to investigate for the rotation on Android but I need help on iOS

@lejard-h
Copy link
Collaborator

changing dimension is now supported in the 0.1.0 release.
https://www.dartdocs.org/documentation/flutter_webview_plugin/0.1.0/flutter_webview_plugin/FlutterWebviewPlugin/resize.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants