'Error adding Flutter web-view plugin in version 1.20.4

I would like to use flutter-web plugin in my app. However, I am getting the following SDK error when I add it to my YAML file. I just upgraded to 1.20.4

How do I fix this error?

The current Flutter SDK version is 1.20.4.

Because app depends on webview_flutter >=1.0.0 which requires Flutter SDK version >=1.22.0 <2.0.0, version solving failed. pub get failed (1; Because app depends on webview_flutter >=1.0.0 which requires Flutter SDK version >=1.22.0 <2.0.0, version solving failed.)

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 12.0) [✓] Android Studio (version 3.6) [✓] VS Code (version 1.49.2) [✓] Connected device (1 available)

• No issues found!

This is the info in my pubspec.yaml file

environment: sdk: ">=2.2.2 <3.0.0"



Solution 1:[1]

webview_flutter package need minSdkVersion 19 so you have to change the app level gradle

android {
    defaultConfig {
        // Required by the Flutter WebView plugin.
        minSdkVersion 19
    }
  }

after upgrade your flutter using flutter upgrade

and then import webview_flutter In your pubspec.yaml file webview_flutter: ^1.0.0 because webview_flutter is stable in flutter 1.22 stable release.

Solution 2:[2]

I was facing the same problem but I did not know the path of that build.gradle so I found it after spending some time.

You have to edit the build.gradle file. In a flutter project, it is found at the path ./android/app/build.gradle.

The parameter that needs to be changed is, of course, minSdkVersion 16, bumping it up to what you need (in this case 19).

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.web_view_example"
    minSdkVersion 19 //This is what you need to change.
    targetSdkVersion 31
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

Solution 3:[3]

For my case, I'm using linkedin_login: ^2.2.1 mean which LinkedIn lib also using webview (iOS is working) but Android it requires to downgrade minSDKVersion to 16. Please open android folder as Android Project in order to see like this. Hope it help you too. enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abhishek Ghaskata
Solution 2 Abdullah Bahattab
Solution 3 Visal SUOS