Flutter - v 1.24.0 to 2.0.5 - pubspec.yaml version problems

Viewed 752

I have downloaded flutter_windows_2.0.5-stable.zip and installed Flutter 2.0.5.

When I run a v1.24.0 project, I get the following output:

Running "flutter pub get" in get_json ...
The current Dart SDK version is 2.12.0-29.10.beta.
Because flutter_easyloading 3.0.0 requires SDK version >=2.12.0 <3.0.0 and no versions of flutter_easyloading match >3.0.0 <4.0.0, flutter_easyloading ^3.0.0 is forbidden.
So, because get_json depends on flutter_easyloading ^3.0.0, version solving failed.
pub get failed (1; So, because get_json depends on flutter_easyloading ^3.0.0, version solving failed.)

Contents of pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  http: ^0.12.2
  json_annotation: ^2.0.0 #^4.0.1
  rflutter_alert:  ^1.1.0 #^2.0.2
  pdf_flutter: ^1.1.4
  syncfusion_flutter_pdfviewer: ^18.4.49-beta
  webview_flutter:  ^1.0.7 #^2.0.4
  flutter_easyloading: ^3.0.0
  cupertino_icons: ^1.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  build_runner: ^1.0.0
  json_serializable: ^2.0.0 #^4.1.1

Looking around the Internet I found Update to/install latest Flutter packages (pubspec.yaml)

At the end of this it is stated that in Flutter 2 it will help to run 1 flutter pub outdated and 2 flutter pub upgrade --major-versions

Running 1 "flutter pub outdated" gives a looot of output and ends with:

Changed 75 dependencies!
25 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
No changes to pubspec.yaml!

Running 2 "flutter pub upgrade --major-versions" also gives a lot of output and ends with:

...
No dependencies changed.
25 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Changed 4 constraints in pubspec.yaml:
  json_annotation: ^2.0.0 -> ^4.0.1
  rflutter_alert: ^1.1.0 -> ^2.0.2
  webview_flutter: ^1.0.7 -> ^2.0.4
  json_serializable: ^2.0.0 -> ^4.1.1

pubspec.yaml was changed to:

dependencies:
  flutter:
    sdk: flutter

  http: ^0.12.2
  json_annotation: ^4.0.1 #^4.0.1
  rflutter_alert: ^2.0.2 #^2.0.2
  pdf_flutter: ^1.1.4
  syncfusion_flutter_pdfviewer: ^18.4.49-beta
  webview_flutter: ^2.0.4 #^2.0.4
  flutter_easyloading: ^3.0.0
  cupertino_icons: ^1.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  build_runner: ^1.0.0
  json_serializable: ^4.1.1 #^4.1.1

Now I try run my (old) project again which results in the following output:

Running "flutter pub get" in get_json...
The current Dart SDK version is 2.12.0-29.10.beta.
Because no versions of json_serializable match >4.1.1 <5.0.0 and json_serializable 4.1.1 requires SDK version >=2.12.0 <3.0.0, json_serializable ^4.1.1 is forbidden.
So, because get_json depends on json_serializable ^4.1.1, version solving failed.
pub get failed (1; So, because get_json depends on json_serializable ^4.1.1, version solving failed.)

I have tried many variations of what is described above, but I am stuck.

Can anyone help or guide me in the right direction? Thank you.

==============================

Thank you to Ujjwal Raijada. I got Flutter 2 because of web support and did not think of null safety. However, I have now followed the migration guide to the detail and now have the following pubspec.yaml:

environment:
  sdk: '>=2.12.0 <3.0.0'

dependencies:
  flutter:
    sdk: flutter

  http: ^0.13.1
  json_annotation: ^4.0.1
  rflutter_alert: ^2.0.2
  #pdf_flutter: ^1.1.4 # Package pdf_flutter is not null safe and therefore cannot be used ...
  syncfusion_flutter_pdfviewer: ^19.1.57-beta
  webview_flutter: ^2.0.4
  flutter_easyloading: ^3.0.0
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^2.0.1
  json_serializable: ^4.1.1

I have also changed my code as suggested by the migration guide. so now I run "flutter packages pub run build_runner build" which results in:

The pubspec.yaml file has changed since the pubspec.lock file was generated, please run "pub get" again.
pub finished with exit code 65

Pressing "pub get" in pubspec.yaml gives the following result:

The current Dart SDK version is 2.12.0-29.10.beta.
Because get_json requires SDK version >=2.12.0 <3.0.0, version solving failed.
pub get failed (1; Because get_json requires SDK version >=2.12.0 <3.0.0, version solving failed.)
Process finished with exit code 1

What should I do now? Any help out there? Thank you.

0 Answers
Related