The library 'package:vin_decoder/vin_decoder.dart' is legacy, and should not be imported into a null safe library - flutter

I am trying to use a vin decoder package in my app. When I import the package:
import 'package:vin_decoder/vin_decoder.dart';
but I am getting this warning:
The library 'package:vin_decoder/vin_decoder.dart' is legacy, and should not be imported into a null safe library.
Try migrating the imported library.
My pubspec.yaml has this under dependencies:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
vin_decoder: ^0.1.4
Can someone explain what I am doing wrong? I checked out this stack overflow question but nothing worked.
Thank you.

You are doing nothing wrong. Currently this package has not released a null safety version yet, and you project is null safe. Check package, there is a prerelease version 0.2.1-nullsafety. Either wait for it to be released, or use this prerelease version, but of course it can contain bugs.

Related

Null safety migration error: package has unmigrated dependencies. But all my dependencies declare support for null-safety

Im trying to migrate dart null safety but I get the following error when I run dart migrate
Bad state: Error: package has unmigrated dependencies.
Before migrating your package, we recommend ensuring that every library it
imports (either directly or indirectly) has been migrated to null safety, so
that you will be able to run your unit tests in sound null checking mode. You
are currently importing the following non-null-safe libraries:
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/basic_project.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/deferred_components_config.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/project.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_driver.dart
file:///C:/flutter/packages/flutter_tools/test/src/test_flutter_command_runner.dart
file:///C:/flutter/packages/flutter_tools/test/src/testbed.dart
package:dwds/data/build_result.dart
package:dwds/data/connect_request.dart
package:dwds/data/debug_event.dart
package:dwds/data/devtools_request.dart
package:dwds/data/error_response.dart
package:dwds/data/extension_request.dart
package:dwds/data/isolate_events.dart
package:dwds/data/register_event.dart
package:dwds/src/debugging/dart_scope.dart
package:dwds/src/debugging/debugger.dart
package:dwds/src/debugging/execution_context.dart
package:dwds/src/debugging/frame_computer.dart
package:dwds/src/debugging/inspector.dart
package:dwds/src/debugging/instance.dart
package:dwds/src/debugging/libraries.dart
package:dwds/src/debugging/location.dart
package:dwds/src/debugging/metadata/class.dart
package:dwds/src/debugging/metadata/function.dart
package:dwds/src/debugging/metadata/module_metadata.dart
package:dwds/src/debugging/metadata/provider.dart
Please upgrade the packages containing these libraries to null safe versions
before continuing. To see what null safe package versions are available, run
the following command: `dart pub outdated --mode=null-safety`.
When I run dart pub outdated --mode=null-safety I got this message and everything seems to be ready for null safety:
C:\flutter\packages\flutter_tools>flutter pub outdated --mode=null-safety
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
[✓] indicates versions opting in to null safety.
All your dependencies declare support for null-safety.
How can I upgrade these packages and migrate to null safety? Appreciate every answer :)
You can use migration helper tool with this command line:
dart migrate
Or you can migrate manually after change min flutter sdk version in pubspec.yaml
environment:
sdk: '>=2.12.0 <3.0.0'
and after this change you need launch this command:
flutter pub get
The tool is listing the following files as non-null-safe:
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/basic_project.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/deferred_components_config.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/project.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_driver.dart
file:///C:/flutter/packages/flutter_tools/test/src/test_flutter_command_runner.dart
file:///C:/flutter/packages/flutter_tools/test/src/testbed.dart
They belong to Flutter itself:
https://github.com/flutter/flutter/tree/master/packages/flutter_tools/test
So you should update Flutter itself. You can do this in pubspec.yaml:
environment:
sdk: ">=2.15.0 <3.0.0"
flutter: ">=2.10.0" # <= here
I am not sure which version got those files migrated, so try the most recent one that does not break your code too much.
That is because you need update your packages, some packages don't have support for null safety , then you need to check each one of your packages ,
for example.. you can looking some package and on the top say if the package have or not have support for null safety (for example the image ), (sometimes users update in other repositories then check on the issues page from GitHub *if the package don't have support)

Can anyone can tell how to solve this issue as i have tried all existing solutions

I have tried all solutions on the internet and everywhere but nothing works so if someone can help me to solve this issue and this issue occurs when i try to make build for my Flutter App project
this is my yaml file
It looks like you might be using an old version of the plugin_platform_interface package.
you should have a line like this in your pubspec.yaml file:
dependencies:
plugin_platform_interface: ^2.0.1
note that according to the instructions on pub.dev this package only supports null safety in version 2.0 and above. see more at
plugin_platform_interface version log
flutter run --no-sound-null-safety
Check this:
Cannot run with sound null safety because dependencies don't support null safety

'package:splashscreen/splashscreen.dart' is legacy, and should not be imported into a null safe library

how to resolve this error of null safe library in splash screen even though I have added dependency most recent one i.e "splashscreen: ^1.3.5"
To import a package without null safety support reduce your flutter version in pubspec.yaml
Replace environment with bellow version
environment:
sdk: ">=2.06.0 <3.0.0"
Note: This is one way to use an external package without null safety support. If it's an existing project check your dependencies for null safety support before migrating.

How is `flutter_localizations` imported into Flutter project when it's not available on pub.dev?

I am wondering how this is possible. The flutter_localizations package is not on pub.dev which makes me think that it's part of flutter package? But if so, how come I have to import it like package:flutter_localizatoins/flutter_localizations.dart into a project?
Check out the official docs
TLDR: In your pubspec.yaml, is not added like a regular dependency
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
It works the same way as flutter(it comes bundled with the sdk itself) which you also import its packages like:
import 'package:flutter/material.dart'
To use localized messages configured with intl package (this is the way from official docs) add this import:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
It will be generated during build.
Use messages this way:
final localizations = AppLocalizations.of(context)!;
print(localizations.hello);
For more details see docs here.

How to make intl to generate dart files with null safety?

Flutter package intl: 0.17.0-nullsafety.2 still generates dart files that don't follow null safety practices.
I also tried adding this with no success:
dependency_overrides:
intl: 0.17.0-nullsafety.2
It still generates folder without null safety.
How to force intl package to generate null safety dart files?
I had the same issue. Here are 3 steps to troubleshoot this:
First of all, update intl dependency in pubspec.yaml to this:
intl: 0.17.0-nullsafety.2
If still doesn't work, then add these 2 fields in the root.
dependency_overrides: intl: 0.17.0-nullsafety.2
Generation also can happen via plugin in Android Studio. I used old one (v 0.12) and after I updated to (v 0.14) it started to generate null safety dart files for localization.
I think I stepped on every rock here.