23

Issue with webview in flutter getting an error

[ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
    PlatformException(error, Trying to create a platform view of unregistered type: plugins.flutter.io/webview, null)

Trying to implement the webview getting the following error

Mangaldeep Pannu
  • 3,738
  • 2
  • 26
  • 45
viveksuggu
  • 737
  • 2
  • 7
  • 12

5 Answers5

62

I had the same problem. But I did these steps, and it helped me:

1) Add Internet permission

<uses-permission android:name="android.permission.INTERNET" />

to the Android manifest: android/app/src/main/AndroidManifest.xml right above application tag.

2) Add this key:

<key>io.flutter.embedded_views_preview</key>
<string>YES</string>

in ios/Runner/Info.plist

3) Add full url (with http://www)

4) Call flutter clean, delete build folder.

Boken
  • 4,825
  • 10
  • 32
  • 42
recvec
  • 894
  • 7
  • 12
9

I Faced this problem and solved it by changing the Android minSdkVersion= 16 to minSdkVersion= 20 you can find it in :

android > app > build.gradle

why minSdkVersion= 20 ?

because I got the exception after using the plugin youtube_player_flutter and in the documentation of the plugin they stated that you should use android minSdkVersion >= 20, unfortunately flutter use by default minSdkVersion= 16, thats why I got PlatformException

My Recommendation Dear reader is to look carefully at the plugins you are using and what version they are supporting on both Android and iOS

Thats all I know ...

MFQ
  • 839
  • 8
  • 14
  • Getting same issue...Any Solution? – Nikhat Shaikh Jun 03 '19 at 05:01
  • @NIKHATSHAIKH did you change the minSdkVersion ? – MFQ Jun 03 '19 at 23:42
  • I have tried changing it but getting same issue : defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.flutterapp" minSdkVersion 20 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } Also have – Ishaan Puniani Apr 28 '20 at 18:15
1

Some Webview support minimumSdk package 21. Refresh the Project after changing minimumSdk

-1

In iOS, you need to register plugins if they use native components.

To do this, you have to import FlutterPluginRegistrant in your project : https://flutter.dev/docs/development/add-to-app/ios/project-setup

import FlutterPluginRegistrant

After, you can use this line to register your plugins :

GeneratedPluginRegistrant.register(with: FlutterViewController)

⚠️ Be careful, you must to register your plugins once during the app lifecycle.

-2

the webview_flutter version in pubspec.lock is different from pubspec.yaml,you can change the version in pubspec.lock and it will solved