'How to avoid lint problem "Depend on referenced packages" for gen_l10n/app_localizations.dart
On my Flutter app, I've got this problem with lint rule : depend_on_referenced_packages
This file is generated here
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 :
Thanks a lot
Solution 1:[1]
Based on the documentation, 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
Solution 2:[2]
I don't know how to ignore only generated packages, but this is how you turn off the rule entirely:
- Create a file
analysis_options.yamlin your project root. - Paste this:
include: package:flutter_lints/flutter.yaml
linter:
rules:
depend_on_referenced_packages: false
Additional information about this file can be found at https://dart.dev/guides/language/analysis-options
Solution 3:[3]
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.
Solution 4:[4]
var string = 'I am here';
string.contains('h');// true
//You can use Regex to find patterns inside a string
string.contains(new RegExp(r'[A-Z]')); // true
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mkobuolys |
| Solution 2 | EzPizza |
| Solution 3 | |
| Solution 4 | Babul |



