Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Null Safety Migration says `Package doesn't exist`

Flutter Null Safety Migration

I am trying to migrate my project to Flutter Null Safety Version and I am following this official migration guide.

When I run the second command it says
Package doesn't exist (the Flutter SDK is not available).

Command I ran

me@My-MacBook-Air my_project % dart --version
Dart SDK version: 2.12.0 (stable) (Thu Feb 25 19:50:53 2021 +0100) on "macos_x64"
me@My-MacBook-Air my_project % dart pub outdated --mode=null-safety
Package doesn't exist (the Flutter SDK is not available).

Flutter Doctor Output

me@My-MacBook-Air my_project % `flutter doctor -v`
Flutter (Channel beta, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale en-IN)
    • Flutter version 2.0.2 at /Users/me/flutter
    • Framework revision 8962f6dc68 (9 days ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/me/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/me/Library/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.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.17.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.3 20D91 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 89.0.4389.90

• No issues found!
like image 337
Abhishek Kumar Avatar asked Mar 20 '21 13:03

Abhishek Kumar


People also ask

What is null safety in Flutter package?

What is null safety in Flutter? Flutter null safety is the feature that became available after the release of version 2 where the minimum version of Dart programming language is set to 2.12. This feature helps to improve developers' productivity by eliminating a whole class of bugs caused by null dereferencing errors.

How do you add no null safety in Flutter?

To set this up in your IDE of choice, you can use “Edit Configurations” (in your run configurations) → “Additional run args” in IntelliJ and search for “Additional Args” (with “Dart”/”Flutter”) in your setting. Open Edit Configurations in Run. Select on Add Additional Run args. Just add –no-sound-null-safety there.

Is it possible to migrate a flutter project to null safety?

It's actually possible to use packages that don't support null safety in your project and still migrate to null safety. It's even possible to slowly migrate your project piece by piece to null safety too. I ended up in this precidament with one of my projects because I made the mistake of depending on charts_flutter.

When should I migrate my null-safe package?

You can — and should — migrate your package before packages that depend on it are migrated. Your null-safe package is usable by packages and apps that don’t use null safety yet, as long as they use Dart 2.12 or later.

Is my dart or flutter package null safe?

For example, the Dart and Flutter core libraries are null safe, and they’re still usable by apps that haven’t migrated to null safety. This section tells you how to check and update your package’s dependencies, with the help of the dart pub outdated command in null-safety mode.

Is there a flutter package for flutter SDK?

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.


1 Answers

Try flutter pub outdated --mode=null-safety, should display the the migration state of your package’s dependencies.

like image 77
Elie Omatuku Avatar answered Oct 17 '22 22:10

Elie Omatuku