Use a non null saftey package inside a null saftey enabled app dart

1,188

Solution 1

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

Solution 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).

Share:
1,188
Farhan Syedain
Author by

Farhan Syedain

Updated on December 31, 2022

Comments

  • Farhan Syedain
    Farhan Syedain over 1 year

    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

    • Jitesh Mohite
      Jitesh Mohite almost 3 years
      heve you pubspec fro the specific lib, maybe you need to upgrade version.
    • Farhan Syedain
      Farhan Syedain almost 3 years
      There is no null-safety version available
    • Jitesh Mohite
      Jitesh Mohite almost 3 years
      then update pubspec lib version, it should work
  • Farhan Syedain
    Farhan Syedain almost 3 years
    thanks, but actually i found another solution.
  • Arijeet
    Arijeet almost 3 years
    Can you tell us about that solution of yours ?