4

So , there is this package which doesn't have null safety in any of its versions. Is there any way i can use it inside my project where i am using null safety.

Here is the error that my IDE is showing me : enter image description here

Farhan Syedain
  • 408
  • 3
  • 12

4 Answers4

2

You should not use non null-safe packages in a null safe app.

  1. You can try to migrate it yourself (clone the repo, make the changes, etc...)

  2. I've checked github_sign_in's github repo and found that there's a pending pull request with null-safety.
    That request goes from this repository which is null-safe.

You can use it (at your own risk) instead of the original one:

dependencies:
  github_sign_in:
    git:
      https://github.com/Gene-Dana/dart-github-sign-in

PS. Note that it does not support Flutter Web (as from the comments).

Thepeanut
  • 3,074
  • 1
  • 17
  • 23
2

So, in case your app depends on some packages which don't have null safety. You can run your app with unsound null safety. For that run this command.

flutter run --no-sound-null-safety

For dart files :

dart --no-sound-null-safety run

So , what basically this does is runs some of your code with null safety and the part that is not eligible for null safety without null safety.

Reference from this article

Farhan Syedain
  • 408
  • 3
  • 12
0

As your IDE says you would have to migrate the package yourself otherwise it won't be possible. If you want to learn more about migrating to null safety you can refer to the Dart Docs

Yusuf-Uluc
  • 887
  • 4
  • 15
0

add this at top of code :-

// @dart=2.9
umar_baloch
  • 183
  • 1
  • 10