I am using flutter_webview_plugin: ^0.3.8 to open up a webview in my flutter app.
When I click on a button, a webview is opened.
I can do it in 2 ways.
FlutterWebviewPlugin flutterWebviewPlugin = FlutterWebviewPlugin();
1) flutterWebviewPlugin.launch('https://google.com',withJavascript: true);
The problem is that it opens google in a webview but it occupies the entire screen available. It doesn't respect the safearea or anything else defined in parent widget and not sure how to add a back button in the app bar.
And I can close it with flutterWebviewPlugin.close()
2)Navigator.push<dynamic>(
context,
MaterialPageRoute<dynamic>(
builder: (BuildContext context) => WebviewScaffold(
url: 'https://google.com',
withJavascript: true,
appBar: AppBar(
title: Text("Widget webview"),
),),),);
This respects the safearea and I can also have an app bar with a back button but I am unable to close this. flutterWebviewPlugin.close() doesn't seem to work.
I also have a dispose method:
flutterWebviewPlugin.dispose();
super.dispose();
}
I need a way to close out of WebviewScaffold or size flutterWebviewPlugin according to parent widget. How do I do that?
You can use package https://pub.dev/packages/flutter_inappbrowser (EDIT: it has been renamed to flutter_inappwebview)
allows you to add an inline webview
demo show inline webview with default project
full example code