Flutter: Why you should not use the official WebView Plugin

Tl;dr: Use flutter_inappwebview instead. It is rich in feature, and the switching process only takes a few minutes.

Image for post
Image for post

have developed Flutter applications for a few years and some of you may have the same thought with me: the official plugins are better. Well, we were wrong. I have switched away from the official Flutter WebView plugin, and I think you should too.

3 months ago I published an article: Flutter: How to make WebView transparent”, that worked fine but it was only a temporary fix. There are still no official responses on whether they will merge it or not, or whether this feature will be added or not.

Luckily there is another plugin: flutter_inappwebview. The switching is simple, just change WebView to InAppWebView and do a few adjustments on the parameters and you’re done. Here are some features that are worth looking at:

Set Transparent Background

Setting transparent background is simple:

InAppWebView(
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
transparentBackground: true,
),
),
);

Add/Remove JavaScript Handlers

In the official WebView plugin you can only add JavaScript handlers by putting them into the widget tree (the javascriptChannels parameter), this is kind of inconvenient. In flutter_inappwebview, you can add or remove JavaScript handlers anywhere once you have the InAppWebViewController instance, nice!

Access Camera and Photo Album

As far as I know, if your website needs to access camera and photo album (e.g. uploading an image), you can’t do it with the official WebView plugin. But with flutter_inappwebview you can! Head to the documentation for instructions.

Finally, I really appreciate pichillilorenzo who created this amazing plugin. Everyone should use it instead of the official one from the Flutter team.

Do you know you can clap up to 50 times for an article? Go smash that button!

A JavaScript/Node/Flutter developer who love technical stuffs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store