so this the widget_test.dart
and these are the problems
check pubspec.yaml file whether you have included flutter and flutter_test appropriately
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
and make sure indentation in yaml file is correct.
if problem does not solved. run flutter clean and flutter pub get
Related
I am currently trying to implement localization in my Flutter App but whenever I try to add the dependency for flutter_localization, I get the following error Message:
Because the timer depends on flutter_localization from SDK which doesn't exist (could not find package flutter_localization in the Flutter SDK), version solving failed.
I have also correctly added the path to both my flutter and dart SDKs in Android Studio.
Here is my pubspec.yaml file:
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
dependencies:
flutter:
sdk: flutter
intl: ^0.17.0-nullsafety.2
cupertino_icons: ^1.0.2
sqflite: any
shared_preferences: ^2.0.15
path_provider: any
flutter_localization:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
I can't access GlobalMaterialLocalizations without flutter_localization and apparently, this is the easiest solution. I have already tried many solutions like checking version compatibilities and updating all dependencies. can you guys help me out?
Thanks in Advance!
Upgrading SDKs, Upgrading Dependencies, reinstalling flutter and Dart, and more
You misspelled the package
Replace
flutter_localization:
sdk: flutter
With
flutter_localizations:
sdk: flutter
Take note on the s on flutter_localizations
i have install firebase tools for implement it in flutter, i followed all the instruction but when i run "flutterfire configure" this error appears (FlutterAppRequiredException: The current directory does not appear to be a Flutter application project.)
You need to first redirect to your application path in CLI
cd app_name
Try again flutterfire configure command after that.
You must make sure that in your pubspec.yaml the following lines are on the start of dependencies place, ex:
dependencies:
flutter:
sdk: flutter
Make sure your pubspec.yaml file is well defined and correct.
In my case, I had erased after dependencies
flutter:
sdk: flutter
...
The correct format may be in flutter 3.3.0 Flutter and the pubspec file
name: myapp
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment:
sdk: '>=2.18.0 <3.0.0'
dependencies:
cupertino_icons:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
assets:
- assets/
uses-material-design: true
I added the flutter package "flutter_launcher_icons" but get problems when try to use it.
My "pubspec.yaml":
environment:
sdk: ">=2.13.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_blue: ^0.8.0
csv: ^5.0.0
share: ^2.0.4
path_provider: ^2.0.2
flutter_launcher_icons: ^0.9.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/Logo.png"
adaptive_icon_background: "assets/launcher/background.png"
adaptive_icon_foreground: "assets/launcher/foreground.png"
When I run "pub get" I get this (looks OK):
C:\src\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in ble_thms... 790ms
Process finished with exit code 0
But when I try to run the "flutter_launcher_icons" I get this:
C:\src\flutter\packages\flutter_tools>flutter pub run flutter_launcher_icons:main
Could not find package "flutter_launcher_icons". Did you forget to add a dependency?
pub finished with exit code 65
When I try to install "flutter_launcher_icons via terminal its the same:
C:\src\flutter\packages\flutter_tools>flutter pub get flutter_launcher_icons
Running "flutter pub get" in .... 894ms
C:\src\flutter\packages\flutter_tools>flutter pub run flutter_launcher_icons:main
Could not find package "flutter_launcher_icons". Did you forget to add a dependency?
pub finished with exit code 65
How can I solve this problem to use the package "flutter_launcerh_icons"? I also already tried "pub upgrade" and "pub outdated".
add the dependency **flutter_launcher_icons** like so:
flutter pub add flutter_launcher_icons
then:
flutter pub run flutter_launcher_icons:main
Hope this helps anyone with the same issues in the future.
The dependency is dev dependency, so it must go under dev_dependencies list.
dev_dependencies:
flutter_launcher_icons: "^0.9.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
Dev dependency are not necessarily ran on "flutter run", but rather with specific command, like:
flutter pub run flutter_launcher_icons:main -f "pubspec.yaml'
Please refer to installation guide on pub.dev
You should be try to use below dependency:
flutter_launcher_icons: ^0.8.0
Below is your pubspec.yaml file:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.8.0"
flutter_icons:
image_path: "assets/icon/Logo.png"
android: true
ios: true
Prepare an app icon for the specified path. e.g. icon/icon.png
Execute command on the terminal to Create app icons:
flutter pub get
flutter pub run flutter_launcher_icons:main
OK, it seems that there is a problem with the flutter_tools and the dependence on "image"
C:\src\flutter\packages\flutter_tools>flutter pub add flutter_launcher_icons
The current Dart SDK version is 2.13.4.
Because flutter_launcher_icons <0.4.0 requires SDK version >=1.20.1 <2.0.0 and flutter_launcher_icons >=0.4.0 <0.7.1 depends on image ^2.0.0, flutter_launcher_icons <0.7.1 requires image ^2.0.0.
And because flutter_launcher_icons >=0.7.1 <0.9.0 depends on yaml ^2.1.15 and flutter_launcher_icons >=0.9.0 depends on args 2.0.0, every version of flutter_launcher_icons requires args 2.0.0 or image ^2.0.0 or yaml ^2.1.15.
And because flutter_tools depends on both args 2.1.0 and yaml 3.1.0, every version of flutter_launcher_icons requires image ^2.0.0.
So, because flutter_tools depends on both image ^3.0.2 and flutter_launcher_icons any, version solving failed.
Can I "downgrade" somehow the "flutter_tools" ?
Found the problem:
I somehow changed the path in the Android Studio Console to "C:\src\flutter\packages\flutter_tools".
So I changed it back to the project path "C:\src\Android\AndroidStudioProjects\my_flutter_project".
Now it is working.
Clumsy mistake from my side. :-(
This is how I solved my problem, type this command in the code editor terminal:
flutter pub add package_name
or, if it already exist:
flutter pub upgrade package_name
Hopefully it will solve the problem
I got the same error and i find that i wrote laucher instead of launcher in my command line
I just solved the same error you have, and it was something so simple that many of us do not realize it sometimes.
Verify that the terminal is in your project folder.
Try putting flutter_launcher_icons: any in the dev_dependencies: section like in the image.
Verify correct indentation in pubspec.yaml
click to see image
I had the same problem,
flutter clean
then
flutter pub get
solved it.
I have an app (with null-safety), and want to use integration_test package to do some testing. The pubspec.yaml looks like:
dependencies:
archive: ^3.1.2
...
dev_dependencies:
build_resolvers: ^2.0.0
build_runner: ^1.11.5
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
...
Then it errors:
Because every version of flutter_driver from sdk depends on archive 2.0.13 and my_app depends on archive ^3.1.2, flutter_driver from sdk is forbidden.
I cannot use the non-null-safety version (2.x) of archive package, because if I do so, my app code will fail to run in null safety mode! I can accept that my tests run in non-null-safety mode, but I cannot tolerate my app code run in non-null-safety mode.
Thanks for any suggestions!
You need to override the archive package version to tell flutter_driver to use the latest one:
dev_dependencies:
build_resolvers: ^2.0.0
build_runner: ^1.11.5
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
dependency_overrides:
archive: ">=3.1.2"
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.