Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 402 Vote(s) - 3.59 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The library 'package:flutter/material.dart' is legacy, and should not be imported into a null safe library

#1
I have a null-safe library and in the example folder I'm using the following import:

```
import 'package:flutter/material.dart';
```

However, the linter is giving me the following warning:

> The library 'package:flutter/material.dart' is legacy, and should not be imported into a null safe library. Try migrating the imported library. import_of_legacy_library_into_null_safe

The example project's pubspec.yaml file specifies the beta version of the Dart SDK:

```
environment:
sdk: ">=2.12.0-29.10.beta <3.0.0"

dependencies:
flutter:
sdk: flutter
my_library:
path: ../
```

Hasn't material.dart already been converted by now? Do I need to add something else to pubspec.yaml or just wait for the stable release to come out?
Reply

#2
The fix for this is relatively simple.
Just go to your pubspec.yaml file and make sure the lottie dependancy that you have there, is the latest version as on the pub.dev site.
Reply

#3
go to

[To see links please register here]

,

copy the latest release version of font i.e in my case (font_awesome_flutter: ^9.1.0),

then add it to your pubspec.yaml file i.e (font_awesome_flutter: ^9.1.0),

click pub get dependencies

go to your input_page file

click get dependencies
Reply

#4
[![The library 'package:flutter_*/*.dart' is legacy, and should not be imported into a null safe library. Try migrating the imported library.

Open run/debug option -> select edit configuration as shown in image one.][1]][1]


[![And then add in --no-sound-null-safety in Additional run args section ->Apply->ok->run appllication it works for me][2]][2].imgur.com/A9aEb.png


[1]:

[To see links please register here]

[2]:
Reply

#5
Use `dart pub outdated --mode=null-safety` and then `dart pub upgrade --null-safety` to upgrade all your dependencies to null-safety.

For more details go to

[To see links please register here]

.
Reply

#6
Copy the latest version of the package which is giving the error from

[To see links please register here]

and paste it in the pubspec.yaml file.
Reply

#7
Currently, on 8/29/2021, a*uto_size_text package also keeps giving this alert*, because I was using the Null Safety versions of Dart - 2.12.0, and to solve this, I looked in the package documentation and saw that I had a **Prerelease version to Null Safety** - launch, so I used it.

dependencies:
auto_size_text: ^3.0.0-nullsafety.0
Reply

#8
I was facing the same problem with the *Adhan Dart* package, when i read the documentation on the package site , i had the Prereleased version so i made changes to the dependences as `adhan: ^2.0.0-nullsafety.2` and it worked.

For more details:https://pub.dev/packages/adhan/versions/2.0.0-nullsafety.1
Reply

#9
In my case I got this error because I defined 'firebase_core' dependency in the pubspec.yaml file under the 'dev_dependencies' but it was wrong.

I've done 3 easy steps to solve the issue as following:

1- I've got the latest version from

[To see links please register here]

website.

2- I've defined the packages under 'dependencies' in the pubspec.yaml file as following:

dependencies:
flutter:
sdk: flutter
firebase_core: ^2.3.0
3- I've imported the package in the main.dart file as following:

import 'package:firebase_core/firebase_core.dart';

Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Reply

#10
In case someone comes here looking for this error because of the flutter realm package.
Please change your realm version in your `pubspec.yaml` file to a version with null safety. Check out the latest realm versions from

[To see links please register here]

.

Change From
```
dependencies
realm: ^0.0.1
```
To
```
dependencies
realm: ^0.8.0+rc //check for latest version
```

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through