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:
  • 939 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to avoid lint problem "Depend on referenced packages" for gen_l10n/app_localizations.dart

#1
On my Flutter app, I've got this problem with lint rule : [depend_on_referenced_packages][1]

[![enter image description here][2]][2]

This file is generated here

[![enter image description here][3]][3]

Do you have any idea how to solve this without passing by ignore 'depend_on_referenced_packages' ?

in my pubspec.yaml, I only have this :

[![enter image description here][4]][4]


Thanks a lot


[1]:

[To see links please register here]

[2]:

[3]:

[4]:
Reply

#2
Based on the [documentation](

[To see links please register here]

), it seems that just having a dependency on `flutter_localizations` only is not enough. Your dependencies should look like this:

```
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.17.0 # Add this line
```
Reply

#3
I don't know how to ignore only generated packages, but this is how you turn off the rule entirely:
1. Create a file `analysis_options.yaml` in your project root.
2. Paste this:

```
include: package:flutter_lints/flutter.yaml

linter:
rules:
depend_on_referenced_packages: false
```
Additional information about this file can be found at

[To see links please register here]

Reply

#4
I'm using `collection.dart` more than a dozen places in my app and recently after the Flutter 3.0 upgrade this lint started to pop up for me. I think `depend_on_referenced_packages` is a really useful lint to warn you about unnecessary imports. I would never turn it off entirely for the project (@EzPizza's answer).

You can suppress the lint for an affected file by adding this comment to the file:

`// ignore_for_file: depend_on_referenced_packages`

But it's even better to fix the root cause of the problem and include the indicated dependencies into your `pubspec.yaml`. Like for example what @mkobuolys proposes.
Reply

#5
for me it was because the packages i was having this warning on didn't support flutter 3 yet.
Reply

#6
this is [the official link][1]


[1]:

[To see links please register here]


you should direct dependency not indirectly dependency.
Reply

#7
I'm only posting this because the other answers either didn't help me or I didn't understand them.

I got the same warning on a different package, namely page_transition. Here's what I found on why the problem occurs:

> When importing a package, add a dependency on it to your pubspec.
>
> Depending explicitly on packages that you reference **ensures they will always exist and allows you to put a dependency constraint on them to guard you against breaking changes.**

Meaning you are right to look for a solution other than to ignore it.

Here's how I fixed it:
I went to pubspec.yaml and added the following under dependencies:

dependencies:
page_transition: ^2.0.9

You can add the dependency for your package which you would have to look up. I just googled "flutter app_localizations" and this came up, you can see the latest version under the **Installing** tab.
[localization 2.1.0][1]

So, if you're using that package, as an example, you would have to add

dependencies:
localization: ^2.1.0


[1]:

[To see links please register here]

Reply

#8
Just add the package explicitly.
1. run `flutter pub add flutter_gen`
2. run `flutter pub get`

For more info, see

[To see links please register here]

Reply

#9
For me, this error occurs because I accidentally put my package name in the dev_dependencies section. Putting my package name in dependencies section fixed my problem.
Reply

#10
For me, I **accidentally** put the package `url_launcher: ^6.1.7` under `dev_dependencies:`

**Solution:**

I **removed** the package from `dev_dependencies` and **added** it below `dependencies:`
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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