Ask Your Question
0

What is the process for transitioning my code from flutter_webview_plugin to webview_flutter?

asked 2023-05-06 09:26:39 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-06 09:32:02 +0000

bukephalos gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-06 09:26:39 +0000

Seen: 12 times

Last updated: May 06 '23