packages get not fetching .packages for English Words with proper pubspec.yaml - flutter

for context I am currently following this exercise provided by flutter dev: https://codelabs.developers.google.com/codelabs/first-flutter-app-pt1/#3
I use android studio on a Windows 10 profesional.
I have seen this issue across many different areas and I am continually unable to get the English_Words package to upload. I had even uploaded the file directly the .packages and had the import work, however, the functions and classes do not validate
This is the import from main.dart
This is the pubspec.yaml, with the dependency properly spelled out
I had navigated and manually put in the english_words dependency. However, then the methods would not engage, even when the import worked. Furthermore, when I did ''' -flutter packages get ''', the file was removed, even with the .yaml dependency spelled out.
I have done lots of the recommended things:
-flutter doctor
-deleting the pubspec.lock and upgrading/getting packages
-shutting down the virtualization and android studio

cupertino icon and english words must have have a spacing of 2 just like flutter
ex:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words:^3.1.5
this is a YAML file so spacing have a special meaning. just correct it as i did in example enjoy.

Related

How to add a package in the android studio - flutter?

I started fluttering a few days ago. I want to add "font awesome" to my project, but I can't. I searched but could not find the right answer. I finally got this guide, but it doesn't work either.
Adding a package dependency to an app
To add the package, css_colors, to an app:
Depend on it
Open the pubspec.yaml file located inside the app folder, and add css_colors: under dependencies.
Install it
From the terminal: Run flutter pub get.
OR
From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec.yaml.
Import it
Add a corresponding import statement in the Dart code.
4. Stop and restart the app, if necessary
If the package brings platform-specific code (Kotlin/Java for Android, Swift/Objective-C for iOS), that code must be built into your app. Hot reload and hot restart only update the Dart code, so a full restart of the app might be required to avoid errors like MissingPluginException when using the package.
In the dependencies: section of your pubspec.yaml, add the following line:
dependencies:
font_awesome_flutter:
Look here https://pub.dev/packages/font_awesome_flutter/install
It contain examples and instructions.
Steps also the same:
add the package name to dependencies section. It very important to keep the correct number of spaces in every line of pubspec.yaml, it has very sensitive format
in your case:
dependencies:
font_awesome_flutter: ^8.10.0
Click "Packeges get" in top right corner
Import the package into your dart code
in your case:
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Now your can use it in Icon widget
Icon(
FontAwesomeIcons.mars,
size:80.0)

how to "Migrate the plugin to the pubspec platforms manifest"

I have created a new flutter app and after adding cloud_firestore 0.13.0+1 it will not compile. No errors it just stops and removes the row of compile icons. An Analysing spinner revolves forever.
In pub.dev it says to "Migrate the plugin to the pubspec platforms manifest." unfortunately I have been unable to find out where that is or how to do it in the documents or StackOverflow. Please help.
According to documentation, the plugins you required need to be added under dependencies in to a pubsec.yaml file located in the root of your project.
dependencies:
cloud_firestore: ^0.13.0+1
After your plugins are added to pubsec.yaml, you can make use of those dependencies in your code by using imports.
import 'package:cloud_firestore/cloud_firestore.dart';

Flutter web cannot use packages from mobile project

A few months ago I made an android application using flutter. The application requires various dependencies such as intl, cached network image, stopper, carousel_slider, etc.
Then right now I want to convert the project to flutter_web. Here are the steps that I did:
clone github web flutter
I run the command "flutter packages pub global activate webdev"
Then I edited pubspec.yaml and I adjusted it to pubspec.yaml in the previous project (android project)
Here is the contents of pubspec.yaml on the web flutter project:
name: flutter_web.examples.hello_world
environment:
  # You must be using Flutter> = 1.5.0 or Dart> = 2.3.0
  sdk: '> = 2.3.0-dev.0.1 <3.0.0'
dependencies:
  flutter_web: any
  flutter_web_ui: any
  stopper: ^ 1.0.1
dev_dependencies:
  build_runner: ^ 1.4.0
  build_web_compilers: ^ 2.0.0
dependency_overrides:
  flutter_web:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages / flutter_web
  flutter_web_ui:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages / flutter_web_ui
  provider:
    git:
      url: https://github.com/kevmoo/provider
      ref: flutter_web
When I run 'pub dev', an error occurs while resolving the package stopper. Then I tried to open github from the package stopper (https://github.com/aryzhov/flutter-stopper), after that I checked the files in the lib folder. There I found a file called stopper.dart. It turns out that in the file, still using
 import 'package: flutter / material.dart';
So that makes my pubspec error. Because the code should be replaced with
import 'package: flutter_web / material.dart';
Therefore, I tried to outsmart the problem by removing the dependency stopper on pubspec.yaml, then I created a stopper.dart file manually, then I saved it in the lib/mypackages folder. After that, I import stopper.dart from the lib/mypackages folder (it's no longer through the package).
The package stopper is just one of the packages that I use on my Android project. Actually there are many other packages that have the same problem as the package stopper. The point is I have to create the package files manually, then I change "package: flutter / ..." to "package: flutter_web /" manually, then I can import them.
What I want to ask, is there a more elegant and simple way?
Hi the instruction you are following is from an old repository here. As you can see this is discontinued. You can find the informaiton in the REadme.
Instead you should follow the instructions in this page. Read it once carefully and I would suggest to keep a backup of your main project and work on a copy.
First you will have to enable the flutter-web using flutter config --enable-web.
Then you will have to run flutter create .

How to import intl library in Flutter?

I am new in Flutter. When I import the library: import 'package:intl/intl.dart'; , it says that the target of URI doesn't exist:package:intl/intl.dart;
When you import any package, example:
import 'package:intl/intl.dart';
You need to also add the package inside the pubspec.yaml file under the dependencies field example:
dependencies:
intl: ^0.15.7
Then from the terminal you can execute the following command:
flutter packages get
or
From Android Studio/IntelliJ:
Click Packages Get in the action ribbon at the top of pubspec.yaml
more info here:
https://flutter.io/using-packages/
Just to double check, you did import intl: ^0.15.7 into pubspec.yaml; triple check that it has four spaces in front of it (no more and no less); and you ran packages get?
Also, put your focus on the tab for main.dart and hit the green arrow to run it. Sometimes you will then see a popup bar at the top of the screen that tells you pubspec.yaml has changed and you need to run it again from that link in order for it to take. (I've seen that in IntelliJ)
Also, if it's showing red lines under publspec.yaml in the project window but everything is working, that's a bug in the analysis. Ignore it but yes, they do know about it and are working on it. It's often there because, for some reason, pubspec.yaml says your assets directory doesn't exist even though you can access the assets without any problem.
Let IDE do this for you :
flutter pub add intl
After running above command, It will resolve the dependency with the latest version available.
OR
Manual Process
1) Add package in pubspec.yaml file under dependencies field :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
intl: ^0.17.0 // Add this line
2) Execute the following command in terminal :
flutter packages get
3) Import package in your dart file :
import 'package:intl/intl.dart';
if you are facing errors while installing
it coming because of your old version of SDK.
Just fall back to the intl version back by some points in your pubs
intl: ^0.17.0 ---> intl: ^0.16.1 or any other older version like intl: ^0.15.1 etc.
Sometimes its the version of packages which after update not compatible with your old sdk

Target of URI doesn't exist 'package:english_words/english_words.dart'

I'm learning to use Flutter using Android Studio. I'm going through step by step doc provided by Flutter. At Step:2 Use an external package I'm getting issue importing the english_words package. I have properly added the package in pubspec.yaml and clicked Packages Get which added the dependency but at the time of importing the package in lib/main.dart it is saying
Target of URI doesn't exist
'package:english_words/english_words.dart'.
I have seen many questions on StackOverflow but none of them helped me. Please help!
For some packages, once you do all the process described by the other answers to this question, you have to close the Android project and open it again. As well as the emulator.
Some packages need the restart, others do not need it.
After adding the package in the pubspec.yaml file, you need to execute the command flutter packages get or click on "Packages Get" in the action ribbon at the top of pubspec.yaml file.
Then the dependency and any transitive dependency will be added to the .packages file.
Check this:
https://flutter.io/using-packages/
Solution (For VSCode):
Run flutter packages get in pubspec.yml
Restart VSCode
I had the same issue and went about it like listed below and it worked.
1. Add the package
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
**english_words: ^3.1.5**
Save the pubspec.yaml file
go to your terminal and run 'flutter packages get'
4.Close your simulator and rebuild your cradle
Run the main.dart again and it should remove the error.
This is what worked for me, all the best.
Make sure that english_words is on the base-line with flutter:
Took me a lot of time, but in summary, just save the file pubspec.yaml will do. The command flutter pub get will be ran once u save it, then u can import the package.
There is no need to restart ur editor etc.
My solution was to add the "english_words: ^3.1.5" the version at the moment that I write this, under the "dependencies:" and before the "Flutter:" argument, without the "+" sign.
Hope that helps
I used this and it worked for me... without + sign and version in double quote ""..
english_words: "^3.1.5"
Make Sure that the alignment of english_words is correct inside your pubspec.yaml as it's "space sensitive" :
dependencies:
english_words: ^3.1.5 //two spaces
also never align it using tabs, I don't know why but it never works, and don't use + sign
There are so many methods to solve this issue, most of them will get solved on the second step,if not please try third method also it will work.
Run flutter packages get in pubsec.yaml file (if you are using VS Code it will be easier).
Restart your IDE.
Check it now, mostly it will work. If not try third step.
you have to repair pub caches
flutter packages pub cache repair
I hope it will work. if all methods are not working try to re install flutter.
my friend solution is so simple only add this code line in file pubspec.yaml
english_words: ^3.1.0
like this
dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
english_words: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
it would work perfectly:)
I faced the same issue but I managed to solve it using the steps below:
add the package as an example english_words: ^3.1.0" in 'pubspec.yaml file.
save file or press ctrl+s
//the Output Console will appear this message
[app name] flutter packages get.
Running "flutter pub get" in first_app..., 2.4s
exit code 0.).
3. check main.dart file, the error will be removed.
For me nothing worked. Things resolved only after
Flutter upgrade
in pubsec.yaml file
For those who are still experiencing this problem, it took me hours to figure out what was wrong. Basically, if all the other answers don't work:
Open the test/.packages file on whatever IDE you are using
Locate the package that is not working and go to that directory on your computer.
Delete the whole package. In my case it was the whole english_words package folder.
In the pubspec.lock and .packages file, delete all instances of that package.
run pub get
In the docs of https://flutter.dev/docs/get-started/codelab there is the following code:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
+ english_words: ^3.1.5
The thing which is causing the error is "+ sign". I just removed it and all worked fine for me.
Delete the plus sign "+" in front of english_words (if you have one)
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^3.1.5
I got the same issue.
It is observed only in version 4.0.0 .For lower versions there is no problem.
So here is what you can do to solve this:
Download code for the dependency from :
https://github.com/filiph/english_words
Unzip it Rename it to
english_words-4.0.0
Copy this folder.
Now go to flutter's SDK folder and navigate to
.pub-cache\hosted\pub.dartlang.org
and paste the folder english_words-4.0.0 here. Add dependency in pubspec.yaml file. Now run flutter pub get command.
You are good to go.
Note : How to find the path of Flutter SDK
All you need to do is to restart IDE(Android studio or VSCode)
Having this error message:
Error: Cannot run with sound null safety, because the following
dependencies don't support null safety:
package:english_words
I had to change this dependency english_words: ^3.1.5 to the latest version english_words: ^4.0.0 and make "pub get":
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^4.0.0
provider: ^6.0.0
in your pubspec.yaml file, instead of:
english_words: ^4.0.0
try:
english_words: '4.0.0'
it worked for me