Search code examples
flutterdartdependencies

Package Version compatibility issue


I am working on a Flutter project and encountered an issue when trying to add the sendgrid_mailer dependency. Here are my current dependencies in pubspec.yaml:

dependencies:
  cupertino_icons: ^1.0.8
  firebase_auth: ^4.19.5
  firebase_core: ^2.31.0
  flutter:
    sdk: flutter
  google_fonts: ^6.2.1
  intl: ^0.19.0
  mailer: ^6.1.0
  path: ^1.9.0
  path_provider: ^2.1.3
  syncfusion_flutter_pdf: ^25.2.5
  syncfusion_flutter_pdfviewer: any

Error:

flutter pub add sendgrid_mailer
The current Dart SDK version is 3.4.1.

Because google_fonts >=4.0.5 depends on http ^1.0.0 and sendgrid_mailer >=0.1.3 depends on http ^0.13.0, google_fonts >=4.0.5 is incompatible with sendgrid_mailer >=0.1.3.
And because sendgrid_mailer <0.1.3 doesn't support null safety, google_fonts >=4.0.5 is incompatible with sendgrid_mailer.
So, because diagnosis depends on both google_fonts ^6.2.1 and sendgrid_mailer any, version solving failed.

The lower bound of "sdk: '>=2.7.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.

Is there a solution to resolve this dependency conflict? If not, is there an alternative package to sendgrid_mailer that I can use to send emails in my Flutter project?

Any help or suggestions would be greatly appreciated. Thank you!


Solution

  • The reason behind your project's dependency conflicts is that, google_fonts depends on http ^1.0.0 while on the other hand sendgrid_mailer depends on the http ^0.13.0. to solve the issue you just need to simply override the http version.

    try this:

    dependency_overrides:
      http: ^0.13.0
    
    dependencies:
      cupertino_icons: ^1.0.8
      firebase_auth: ^4.19.5
      firebase_core: ^2.31.0
      flutter:
        sdk: flutter
      google_fonts: ^6.2.1
      intl: ^0.19.0
      mailer: ^6.1.0
      path: ^1.9.0
      path_provider: ^2.1.3
      sendgrid_mailer: ^0.1.3
      syncfusion_flutter_pdf: ^25.2.5
      syncfusion_flutter_pdfviewer: any
    

    that is all you need to do.