I have a flutter package that uses effective_dart which is working as expected.
(I've explicitly tested this by adding/removing the include and ensure that warnings come and go as expected.)
I have the effective_dart dependency in my pubspec.yaml as follows:
name: sounds
version: 0.9.1
repository: https://github.com/bsutton/sounds
homepage: https://github.com/bsutton/sounds
documentation: https://github.com/bsutton/sounds/wiki
description: Sounds provide a complete api and Widgets for audio playback and recording. Both iOS and Android are supported.
environment:
sdk: '>=2.1.0 <3.0.0'
flutter: '>=1.17.0 <2.0.0'
dependencies:
device_info: '>=0.4.2+4 <2.0.0'
flutter_spinkit: ^4.0.0
meta: ^1.1.8
path: ^1.6.4
path_provider: ^1.6.7
provider: ^4.1.0
sounds_common: ^1.0.1
uuid: ^2.0.4
flutter:
sdk: flutter
dev_dependencies:
pedantic: ^1.9.0
effective_dart: ^1.2.1
dshell: ^1.0.0
e2e: ^0.5.0
lint: ^1.1.1
pub_semver: ^1.4.4
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
flutter:
plugin:
platforms:
android:
package: com.bsutton.sounds
pluginClass: Sounds
ios:
pluginClass: Sounds
The analysis_options.yaml contains:
include: package:effective_dart/analysis_options.yaml
analyzer:
errors:
todo: ignore
strong-mode:
implicit-casts: false
implicit-dynamic: false
The problem is that I keep getting a warning about the include not being found.
If I make a trivial edit (add a commented out blank line) to the analysis_options.yaml file the error goes away for a while but invariably returns (generally after a restart of the ide).
I'm using vs code but believe I've seen it in android studio (although I can't reproduce it now).
The error:
The include file package:effective_dart/analysis_options.yaml in /home/bsutton/git/sounds/analysis_options.yaml cannot be found.
The problem is having no material impact on my project but its just really annoying to have a warning always showing up.
Using the command given below is worked for me. Let you try it in the terminal.
flutter pub add --dev flutter_lints
(restart VSCode if the warning is still shown)
This seems to be a problem with sub projects (your example folder). See https://github.com/dart-lang/sdk/issues/42910
You can try to exclude the example in your root analysis_options.yaml:
analyzer:
exclude:
# workaround for https://github.com/dart-lang/sdk/issues/42910
- 'example/**'
And then add a separate analysis_options.yaml to the example.
If someone is still looking for the answer for the same error, this worked for me.
I have added flutter_lints: ^1.0.4 in dependencies in pubspec.yml file.
And the error gone.
you can try this command
flutter pub add --dev flutter_lints
if didn't work use this command
flutter pub upgrade flutter_lints
It show's up cuz the project import the flutter lints (as it says to encourage good coding practices). Usually, there's a hashtag in front of it that makes it functionless. When there was no hashtag, it was activated and found for the flutter lints package.
Solution:
Add hashtag # in front of it.
Add flutter_lints: ^1.0.4 package in pubspec.yaml file.
Related
I made a clone of this project from Github, the project uses localization to support multiple languages. After I cloned the project I went to pubspec.yaml:
name: converterpro
description: Unit and currencies converter
publish_to: none
version: 3.2.1+37
environment:
sdk: ">=2.15.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
#Needed to store the customizations and the latest currencies convertions
shared_preferences: ^2.0.15
#Needed to open external pages such as GitHub repo, Play Store, etc
url_launcher: ^6.1.5
#Needed for the state management
provider: ^6.0.3
#Needed for translation
intl: ^0.17.0
#Needed for fonts
google_fonts: ^3.0.1
#Needed for navigation between pages
go_router: ^5.0.0
#Needed for Android App Shortcuts
quick_actions: ^1.0.0
#Calculator widget
calculator_widget:
path: packages/calculator_widget
#Needed for updating exchange rates
exchange_rates:
path: packages/exchange_rates
#Needed for app translation
translations:
path: packages/translations
#Needed for unit conversion
units_converter: ^2.0.1
#git:
# url: https://github.com/ferraridamiano/units_converter
#path: ../units_converter
flutter_localizations:
sdk: flutter
dev_dependencies:
test: ^1.21.4
flutter_native_splash: ^1.2.3
flutter_lints: ^2.0.1
msix: ^3.6.3
flutter_test:
sdk: flutter
flutter_native_splash:
# Customize the parameters below, and run the following command in the terminal:
# flutter pub run flutter_native_splash:create
# To restore Flutter's default white splash screen, run the following command in the terminal:
# flutter pub run flutter_native_splash:remove
color: "#eeeeee"
color_dark: "#333333"
image: resources/splash/splash.png
msix_config:
display_name: Converter NOW
publisher_display_name: Damiano Ferrari
identity_name: 39826DamianoFerrari.ConverterNOW
logo_path: resources\images\logo.png
output_name: converternow-windows
publisher: CN=E8FE6044-F04C-422E-AC68-EDA83F6AAFB2
capabilities: internetClient
flutter:
uses-material-design: true
generate: true
assets:
- resources/images/
and clicked on pub get to get all the dependencies listed in the pubspec.
when I went back to my main.dart file to run my app I stumbled upon this error:
The IDE suggested creating a `app_localizations.dar' file, but nothing happened!
Can someone helps me figure out what is going on and how to solve this error
In the README you can find all the instructions to build from source. The project uses Melos for manging the monorepo, so you first need to install it with dart pub global activate melos and then bootstrap it with melos bootstrap. This command retrieve all the packages and generates the translation code. That's because you got that error about translations.
Seems if a plugin package is included in pubspec.yaml, it will be included in build even not use.
Take my sample project https://github.com/J-Siu/flutter_scroll as example, pubspec.yaml
name: flutter_scroll
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
google_sign_in: ^5.4.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
google_sign_in is a plugin but not imported in any of the source code and there is no dependency using it.
However if you go to the demo page: https://j-siu.github.io/app/flutter_scroll/#/ , open browser inspector -> network, reload the page, you will see https://apis.google.com/js/platform.js is loaded. That is done by google_sign_in initialization.
Question: Other than removing it from pubspec.yaml, is there a way to exclude plugin from final build if it is not imported in source and other dependency?
PS: You can experiment with a plain starting project:
flutter create --platforms web my_testing
cd my_testing
flutter pub add google_sign_in
flutter run (should open chrome)
check inspector -> network with reload
No, i dont think its possible to not use a package thats defined in pubspec during build. You could take a look at packages like
Dependency validator
Where you get to know which packages arent used at all and remove them easily.
I have imported a project in android studio flutter. But, there is an incredible amount of version conflict coming in. If one solves other rises and if that goes down, other one rises. I am trying to get all packages and it is showing me the following error as below.
Because date_utils >=0.1.0+3 depends on intl ^0.16.0 and prokit_flutter depends on intl 0.17.0-nullsafety.2, date_utils >=0.1.0+3 is forbidden.
So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.
pub get failed (1; So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.)
Process finished with exit code 1
And my pubspec.yaml code is as below.
name: prokit_flutter
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
url_launcher: 5.0.3
nb_utils: 3.1.6+7
google_fonts: 1.1.0
animations: 1.1.2
intl: 0.17.0-nullsafety.2
http: 0.12.2
firebase_core: 0.5.0
firebase_analytics: 6.0.0
firebase_crashlytics: 0.1.4+1
google_sign_in: 4.5.3
html: 0.14.0+3
share: 0.6.5
mobx: ^1.2.1+2
flutter_mobx: ^1.1.0+2
flutter_statusbarcolor: 0.2.3
simple_animations: 1.3.8
snaplist: 0.1.8
flutter_svg: 0.18.1
flutter_slidable: 0.5.7
flutter_staggered_grid_view: 0.3.2
flutter_staggered_animations: 0.1.2
geolocator: 5.3.2+2
geocoder: 0.2.1
google_maps_flutter: 0.5.21+3
clustering_google_maps: 0.1.2
razorpay_flutter: 1.2.2
signature: 3.2.0
liquid_swipe: 1.5.0
lipsum: 1.0.1
flutter_colorpicker: 0.3.4
clippy_flutter: 1.1.1
flutter_tags: ^0.4.8
image_picker_gallery_camera: 0.1.6
video_player: 0.10.11+2
charts_flutter: ^0.9.0
like_button: ^1.0.1
flutter_reaction_button: ^1.0.1
lottie: ^0.6.0
showcaseview: ^0.1.6
date_utils: ^0.1.0+3
cached_network_image: ^2.3.1
flutter_localizations:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
mobx_codegen:
build_runner: ^1.9.0
#flutter packages pub run build_runner build
flutter:
uses-material-design: true
assets:
- images/smartDeck/images/
fonts:
- family: Andina
fonts:
- asset: fonts/andina.ttf
And there are 4-5 dependency version error. How can I solve this version error thing in one click or I can just somehow skip this version problem and get the thing done. Please help, Thanks in Advance.
Whenever conflicts between dependencies occur, the simplest solution is to just remove the version number of both that dependencies and type 'any' without quotes in front of them.
for example let's say this following two dependency conflicts:
shared_preferences: ^0.5.7+3
requests: ^3.3.0
then do following:
shared_preferences: any
requests: any
After this do pub get and issue will be resolved. Now, most importantly, don't leave any dependency on this form. instead goto pubspec.lock file and search these two dependencies. Flutter itself chooses the versions that don't conflict, copy those and replace it to pubsec.yaml
You can use dependency_overrides in your pubspec.yaml to force a specific package version. The package version will override any reference to a dependency in the entire app.
In your case you could use
dependencies:
flutter:
sdk: flutter
...
cupertino_icons: ^1.0.0
dependency_overrides:
intl: ^0.17.0-nullsafety.2
See dependency_overrides for more information.
Replace intl: 0.17.0-nullsafety.2 version with intl: 0.16.1 and remove intl from dependency overrides.
Now, run pub get command.
You can simply change the version of package that is causing conflic with another version which is compatible with your dart SDK. I tried it and the problem was solved.
had the same problem; ran the following command:
flutter pub upgrade --major-versions
if you don't mind having the latest version of all the dependencies while solving version conflict issues, this should be a quick fix.
I had this problem after resetting my Mac mini.
If you still have the pubspec.lock file at the last successful run (or get it from another dev, on that dev's computer the project is still running).
flutter clean.
Replace pubspec.lock by the old one.
Run the project again.
I have an AngularDart-based web project. When I'm try webdev serve, I get this:
[SEVERE] Support for dartdevc in build_web_compilers < 2.0.0 has been removed.
Please upgrade your dependency to:
dev_dependencies:
build_web_compilers: ">=2.0.0"
[SEVERE] Exception: dartdevc is no longer supported by this version
However, I already have the dependency set to "2.0.0 and newer". Here is my pubspec.yaml file:
name: myproject
description: My Description
environment:
sdk: '>=2.3.3 <3.0.0'
dependencies:
angular: ^5.2.0
angular_components: ^0.13.0
dev_dependencies:
angular_test: ^2.2.0
build_runner: ^1.5.0
build_test: ^0.10.3
build_web_compilers: ^2.0.0
pedantic: ^1.0.0
test: ^1.5.1
I tried pub get, pub upgrade, pub activate global webdev, even pub cache repair.
In general, I seem to have problems with dependencies when creating AngularDart projects, even when I use versions from the Dart docs. Is there a magic way to know exactly which version numbers to use?
Try deleting your .dart_tool directory, rerun pub get and try again.
That directory is where dart stores all of the dependencies and artifacts of the build process. Sometimes it can get in an odd state.
Whenever your Dart build is misbehaving in ways that defy explanation, it is good practice to delete the .dart_tool directory first and build clean to see if that fixes it.
I keep getting
Running "flutter packages get" in flutter_sportters...
Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source.
sdk: flutter
^^^^^^^^^^^^^
When I run my app or Packages Get.
It worked perfectly fine before. Have no idea how to fix this.
Consider you are going to use this package "shared_preferences".
You will get this error in pubspec.yaml. If you did like below.
dependencies:
flutter:
sdk: flutter
shared_preferences: v0.4.2
Indention is important you are accidentally adding shared_preference package below flutter dependency. So the error "A dependency may only have one source"
Correct format below:
dependencies:
flutter:
sdk: flutter
shared_preferences: v0.4.2 #no indention
It throws an error because of Indention. It is important to maintain Indention while adding a dependency in flutter.
Before :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
After :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
Hope this will solve your error.
Happy coding!!!
Indentation !!!
Being newbees making silly mistakes. I have written the new dependency inside the flutter root as :
dependencies:
flutter:
sdk: flutter
sqflite:
Instead of
dependencies:
flutter:
sdk: flutter
sqflite:
Comment when you see the difference!!
I was trying to add assets folder to my project. I added it under dependencies which caused the error:
dependencies:
flutter:
sdk: flutter
assets:
- images/
It's not to be added under dependencies. Instead, add it under flutter:
flutter:
uses-material-design: true
assets:
- images/
You can define just like that in pubspec.yaml file
dependencies:
flutter:
sdk: flutter
image_picker: 0.4.1
and flutter packages get you can call via terminal or if you are using Android Studio than options availbale above when you edit pubspec.yaml file.
In terminal go to your project directory and then enter flutter packages get
I solve My problem:
Here my first Code
dependencies
flutter:
sdk: flutter
webfeed: ^0.4.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
after I change it
dependencies:
flutter:
sdk: flutter
webfeed: ^0.4.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I thing you must to put your package name in the same number colunm of flutter: and cupertino_icons:
Check indentations as flutter package in pubspec.yaml takes single dependency source.
make sure, the name of your project is not same as any package ,
this too cause for this error
open your pubspec.yaml file
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
country_code_picker: ^1.0.4
Other answers are correct. I would also like to add that I was trying to add shared_preferences and even though my indentation was correct, I was still getting the error mentioned in the question. To resolve it I changed the name of my project as it was also shared preferences
I kept getting this error no matter what I did, including commenting out the new lines. Finally, I put them back in with the correct indentation and ran the program. The problem magically resolved itself. However, the indentation is critical.
I am getting this error due to duplication of a package in dependencies
i.e:
dependencies:
flutter:
sdk: flutter
**cupertino_icons: ^0.1.2**
english_words: ^3.1.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I solved this error by removing duplication then Flutter clean and then Flutter Packages Get.
Its due to indentation: check out correct way
name: flutter_app
description: A new Flutter application.
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: "0.11.3+17"
autocomplete_textfield: ^1.6.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I ran into the same problem turns out the name of my app and the package name were same which resulted into this error.
name of the app scrapy and the dependency was also scrapy...
Changed the name and it worked.
After checking all other solutions if the problem still persists
make sure whether the specified library is installed correctly or not. This error also encounter when the library is not installed correctly.