What is flutter_inappwebview
? It’s a Flutter plugin that allows you to incorporate WebView widgets into your Flutter app, to use headless WebViews, or to use In-App browsers.
So, what’s the difference between webview_flutter
(Official flutter plugin) and flutter_webview_plugin
?
Compared to all other WebView plugins, it is feature-rich: a lot of events, methods, and options to control WebViews. Furthermore, they do not have good documentation about their API or, at least, it is not complete. Instead, every feature of flutter_inappwebview
is almost all documented (just check the API Reference on pub.dev).
In this article, I’m going to present the main classes and some examples of the InAppWebView
widget that people were asking about on the official flutter_inappwebview repository (issue section) and on StackOverflow.
This is a list of the main classes that the plugin offers:
InAppWebView
to the widget tree.http://localhost:[port]/
. The default port
value is 8080
.In this article, I’m going to show in particular the InAppWebView
widget, that is the most used/requested one.
Adding the InAppWebView
widget into your app is very simple. It’s just a widget like any other Flutter widget: InAppWebView(initialUrl: 'https://github.com/flutter')
.
NOTE: To use it on iOS, you need to opt-in for the embedded views preview by adding a boolean property to the app’s Info.plist
file, with the key io.flutter.embedded_views_preview
and the value YES
.
This widget has a set of initial attributes that you can use to initialize the WebView:
The list of all available WebView options is quite long, for example, you can enable/disable JavaScript using the javascriptEnabled
option or enable/disable cache using the cacheEnabled
option. The full list of all options is available here.
#flutter #developer