Search code examples
flutterflutterwebviewplugin

How to create webview in flutter


I am trying to use web views in flutter. I have followed this medium article which depicts how we can create a simple application using Flutter embed webview.

https://medium.com/@ekosuprastyo15/webview-in-flutter-example-a11a24eb617f

I am able to create app successfully but right now that app is opening on button click as shown in the above article.

What I want - Now I want to create an application that loads a URL in webview on load (i.e. user won't have to click on any button or link to open that URL).

What we have tried so far?

We have tried flutter url_launcher plugin and flutter_webview_plugin plugin.


Solution

  • Add this lib Flutter WebView

    import 'package:webview_flutter/webview_flutter.dart';
    
    return Scaffold(
          appBar: AppBar(
            title: const Text('Flutter WebView example'),
          ),
          body: const WebView(
            initialUrl: 'https://flutter.io',
            javascriptMode: JavascriptMode.unrestricted,
          ),
        );