Can't run 'flutter pub get' because my sdk version is lower then it should be

Viewed 3444

I have a problem in project. I want to migrate to flutter with null-safty. But when i want to run 'flutter pub get' i get message -

The current Dart SDK version is 2.12.0-133.2.beta.

Because flutter_shareit requires SDK version >=2.12.0 <3.0.0, version solving failed. pub upgrade failed (1; Because flutter_shareit requires SDK version >=2.12.0 <3.0.0, version solving failed.)

My flutter and dart version is

Flutter 2.0.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision adc687823a (4 days ago) • 2021-04-16 09:40:20 -0700 Engine • revision b09f014e96 Tools • Dart 2.12.3

I tried using flutter clean, but still everything stays the same

My pubspec.yaml

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  flutter_icons: ^1.1.0
  dots_indicator: ^2.0.0
  flutter_staggered_grid_view: ^0.4.0
  flutter_point_tab_bar: ^0.2.0
  splashscreen: ^1.3.5




dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: "^0.8.1"

flutter_icons:
  image_path: "assets/icons/logoo.png"   
  android: true
  ios: true

flutter:
  uses-material-design: true

  assets:
    - assets/images/friends/
    - assets/images/posts/
    - assets/images/saved/
    - assets/images/story/
    - assets/images/splash/
  #   - images/a_dot_ham.jpeg

  fonts:
    - family: Ubuntu-Regular
      fonts:
        - asset: assets/fonts/Ubuntu-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
4 Answers

Set the sdk to ">=2.10.0 <3.0.0". Switch to stable and then upgrade flutter to 2.0.

After that you should go through all your packages and upgrade them to null safety first.

Just follow the migration guide for more details

try running the following:

  1. flutter pub outdated
  2. flutter pub --major-version

Make sure you download the new flutter version in the same path of the previous one. If you download it in another path then you should change your Environment path of flutter into the new one.

I just changed my file names

  • Home_Screen.dart to homescreen_dart and
  • Drawer.dart to drawer_widget.dart.

Hope it's Helpful.

Related