Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To transition your code from flutterwebviewplugin to webview_flutter, you can follow these steps:

  1. Add webview_flutter package to your pubspec.yaml file and run pub get to install the package.

  2. Replace the import statement of flutterwebviewplugin to webview_flutter in your dart file(s).

  3. Replace the FlutterWebviewPlugin() constructor to WebView() from the Webview_flutter package.

  4. If you have previously set any configuration like url, headers, initial child, and more in flutterwebviewplugin, you need to update them accordingly. For example:

    a. To set an initial URL, use the initialUrl property of WebView class.

    b. To set headers, use the headers property of WebView class.

    c. To use a custom WebView widget as the initial child of WebView, use the initialChild property of WebView class.

  5. Remove the dispose method from your flutterwebviewplugin code.

  6. You can also use the JavaScriptChannel class for communication between webview and the Flutter app.

  7. Finally, run your code to check if everything is working correctly.

Note that Flutter Team recommends using webviewflutter package to support webviews in your app as flutterwebview_plugin package is outdated and will no longer be supported.