How to add a swagger dependency in pubspec.yaml of flutter

517

You probably should use instead

open_api: ^2.0.1

swagger is deprecated and not compatible with Dart 2 and the requested version 1.0.0 doesn't exist at all.

From https://pub.dartlang.org/packages/swagger#-readme-tab-

enter image description here

Share:
517
Lina
Author by

Lina

Updated on December 09, 2022

Comments

  • Lina
    Lina over 1 year

    I'm a new developers with flutter, and i want to use "swagger" in my application. I add the dependencies of swagger in pubspec.yaml, but there's always an error.

    pubspec.yaml:

    dependencies:
      flutter:
        sdk: flutter
      cupertino_icons: ^0.1.2
      english_words: ^3.1.0
      swagger: ^1.0.0
    

    when i clicked Packages get, this is the following output:

    Running "flutter packages get" in my_first_app...               
    Because my_first_app depends on swagger ^1.0.0 which doesn't match any versions, version solving failed.
    
    pub get failed (1)
    Process finished with exit code 1
    

    How can i use swagger in my Flutter application?

  • Lina
    Lina about 5 years
    When i change the version of swagger to : swagger: ^0.0.2 this is the following output : Running "flutter packages get" in my_first_app... The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297. Because my_first_app depends on swagger >=0.0.2 which requires SDK version >=1.0.0 <2.0.0, version solving failed. pub get failed (1) Process finished with exit code 1
  • Günter Zöchbauer
    Günter Zöchbauer about 5 years
    Why would you do that. The package is deprecated and as I said not compatible with Flutter because it depends on Dart 1.
  • Lina
    Lina about 5 years
    So, i can't use swagger with Flutter ?
  • Lina
    Lina about 5 years
    Thank you, you mean that openapi dependencies replace swagger dependencies in pubspec.yaml up to now
  • Lina
    Lina about 5 years
    how to replace swagger in flutter?
  • Günter Zöchbauer
    Günter Zöchbauer about 5 years
    Sorry, I don't understand the question. open_api is swagger. Just use open_api