In this tutorial you will learn how to use
WebViews in your Flutter application. With WebViews you can embed web contents inside your app. We will use the webview_flutter package that uses native WebViews (WKWebView on iOS and WebView on Android).
The first thing that you have to do is to add the package to your
After this run
flutter pub get, or use the Pub get button.
Now create a new file
webview_scaffold.dart, and create a new
Adding a WebView is very simple, we will need to use the
WebView Widget as the body of the Scaffold. In the following example the WebView will open
We can manage the navigation in our WebView, to do so we will use the
WebViewController object. This is created by the
WebView widget and passed in a callback that’s called once the
WebView is created.
Let’s add the
WebViewController to our state and save it for later, when the callback is invoked.
Now we just need to use the controller to make thee
WebView go back, go forward or reload. The
WebViewController has functions to go back, forward, reload and to check if the
WebView can go back or go forward.
We will put those buttons in a
BottomAppBar as the
bottomNavigationBar of our