“Package doesn’t exist (the Flutter SDK is not available)” when trying to check outdated packages during migration to null-safety

My app is working all good. So now I want to migrate to null-safety.
I’m trying to follow the documentation here.

Here are what I have done:

  1. Update Flutter and Dart to latest stable version. When I do dart --version it shows:
    Dart SDK version: 2.12.1 (stable) (Wed Mar 10 10:18:47 2021 +0100) on "macos_x64"

  2. Update my pubspec.yaml to the null-safety dependencies as much as possible. (Not all packages have migrated to null-safety, but I have updated the ones that has)

  3. Re-run the code and make some tweaks to make sure nothing breaks.

  4. Run dart pub outdated --mode=null-safety to check if there is anything else need to be updated.

At this point, it gives this error message:
Package doesn't exist (the Flutter SDK is not available).

It doesn’t show like in the documentation does.
I tried to flutter clean and rebuild the app but the problem persisted.

Then I tried to create a fresh new flutter project and copy paste the pubspec.yaml contents over.
Then run dart pub outdated --mode=null-safety again, but the same result appears.

Steps to reproduce

  1. Setup Flutter environment for China (documentation)
  2. Create a new fresh flutter project
  3. Copy this code to pubspec.yaml
Click to Expand
environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  cupertino_icons: ^1.0.0 
  bubble_tab_indicator: ^0.1.6
  flutter_i18n: ^0.22.3
  gradient_widgets: ^0.5.2 
  keyboard_dismisser: ^2.0.0
  font_awesome_flutter: ^9.0.0-nullsafety
  sliding_up_panel: ^1.0.2 
  lazy_load_scrollview: ^1.3.0
  pull_to_refresh: 1.6.4 
  date_time_format: ^2.0.1
  like_button: ^2.0.1
  image_picker: ^0.7.2+1
  app_tracking_transparency: ^1.1.0+1

  flutter_facebook_auth: ^3.0.0+1
  sign_in_with_apple: ^3.0.0
  purchases_flutter: ^3.0.2

  flutter_spinkit: ^5.0.0
  sn_progress_dialog: ^0.0.5 # not sure if this is null safe
  shimmer: ^2.0.0-nullsafety.0
  another_flushbar: ^1.10.15
  rflutter_alert: ^2.0.2
  loading: # not null safe
    git:
      url: git://github.com/leonzone/loading.git
      path: loading
      ref: 8f5a63f

  path: ^1.8.0
  path_provider: ^2.0.1
  shared_preferences: ^2.0.4
  flutter_secure_storage: ^4.0.1
  flutter_cache_manager: ^3.0.0-nullsafety.1
  sembast: ^3.0.0+4
  sembast_cloud_firestore_type_adapters:
    git:
      url: git://github.com/tekartik/sembast_flutter_more.dart
      path: cloud_firestore_type_adapters
      ref: dart2
      version: '>=0.1.0'

  flutter_bloc: ^7.0.0-nullsafety.5
  provider: ^5.0.0
  equatable: ^2.0.0
  connectivity: ^3.0.2
  package_info: ^2.0.0
  flutter_device_type: ^0.4.0
  url_launcher: ^6.0.2
  device_info: ^2.0.0
  in_app_review: ^2.0.1
  audioplayers:
    git:
      url: https://github.com/wolfenrain/audioplayers.git
      ref: null-safety

  petitparser: ^4.0.2
  convert: ^3.0.0
  flutter_chips_input: ^1.9.5 
  vector_math: ^2.1.0
  path_drawing: ^0.5.0-nullsafety.0
  matrix_gesture_detector: ^0.1.0

  social_share_plugin: ^0.3.1+1
  share: ^0.6.5+4
  instagram_share: ^0.2.0

  firebase_core: ^1.0.1
  firebase_auth: ^1.0.1
  cloud_firestore: ^1.0.1
  firebase_storage: ^8.0.0
  firebase_database: ^6.1.0
  cloud_functions: ^1.0.0 
  google_mobile_ads: ^0.11.0+3
  firebase_analytics: ^7.1.1

publish_to: none

dev_dependencies:
  flutter_test:
    sdk: flutter

  1. Run flutter pub get
  2. Run dart pub outdated --mode=null-safety

More Information

flutter doctor -v

[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2.2 20D80 darwin-x64, locale en-US)
    • Flutter version 2.0.2 at /Users/ME/development/flutter
    • Framework revision 8962f6dc68 (5 days ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Volumes/Applications/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Volumes/Applications/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.54.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.20.0

[✓] Connected device (2 available)
    • iPho (mobile) • 56ebbe93864be2bfd78acd5fec3456da9ac75123 • ios            • iOS 14.4
    • Chrome (web)        • chrome                                   • web-javascript • Google
      Chrome 89.0.4389.82

• No issues found!

1 possible answer(s) on ““Package doesn’t exist (the Flutter SDK is not available)” when trying to check outdated packages during migration to null-safety

  1. My problem has been found.
    I have been using Flutter_2.0.2/bin/cache/dart-sdk/bin/dart.
    After switching to Flutter_2.0.2/bin/dart, dart pub outdated --mode=null-safety works normally.