I have added the dependency in the pubspec.yaml flie as:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
http: ^0.13.5
And afterward had also run the command **flutter packages get **
Even after this I am unable to import its package in my main.dart file.
import "package:http/http.dart" as http;
Have added this line in my main.dart file but still getting the error and unable to use http methods in my code.
Restart your IDE and Run the Following command:
flutter clean
flutter pub get
Related
Im trying to implement ImagePicker to my Flutter project but when i try to import the package: import 'package:image_picker/image_picker.dart'; it only shows error. I have added it to my pubspec.yaml file as a dependecie but it displayed this error when I reopened the VS:
Because LPP requires SDK version >=2.12.0 <3.0.0, version solving failed.
pub get failed (1; Because LPP requires SDK version >=2.12.0 <3.0.0, version solving failed.)
exit code 1
This is my pubspec.ymal file:
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
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: ^1.0.0
image_picker: ^0.7.2+1
So any help would be great. Thanks in advance :) <3
Which flutter- and dart-version shows "flutter doctor -v"?
Your sdk has to be >= 2.12
If you don't use flutter 2 with dart 2.12 than upgrade flutter (I have currently massive problem with this) or downgrade the versions of sdk, Cupertino-icons and image-picker in the pubspec.yaml-file
Ok so I changed version from 7.2+1 to 6.2 and now it works. :)
when I created a very basic flutter app and ran it for the first time, it works perfectly, and when I try to add some dependencies in my pubspec.yaml file I get no errors in my project but when I run the app by 'flutter run' I get stuck in
Running Gradle task 'assembleDebug'...
(This is taking an unexpectedly long time.)
and the app has never worked
this is my pubspec.yaml file
name: myPDFApp
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
syncfusion_flutter_pdfviewer: ^18.4.35-beta // this is the dep that I want to add
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Add an earlier version of the dependencies, and run pub get. This could solve the issue
I have a Flutter project and from one day to another I could not run packages get anymore. It failes with:
Couldn't read file LocalFile:
'LOCAL_FLUTTER_SDK_PATH\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.6\android\src\main\kotlin\io\flutter\plugins\flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.kt'
even though it exists. Please verify that this file has read
permission and try again.
Also building the app is since that moment not possible anymore, it failes with the same error.
My pubspec.yaml:
name: my_app
description: My fancy cross plattform app
version: 1.0.0+2
environment:
sdk: ">=2.3.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
http: ^0.12.0+2
sqflite:
path:
crypto: ^2.1.3
flutter_typeahead: ^1.7.0
image_picker: 0.3.0
google_maps_flutter: any
http_parser: ^3.1.3
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
intl_translation: ^0.17.7
flutter:
assets:
- assets/
- assets/img/
uses-material-design: true
Note that I created a new project just with the same pubspec.yaml file and there everything works fine. If you have any idea which in my project could cause this error, please tell me I will add that source code then, because the pubspec.yaml seems not to be the reason or at least not the only one.
I have the newest Flutter version (v1.12.13+hotfix.8)
I faced a similar issue. Whenever I run, flutter pub get, I got the following error
flutter Couldn't read file LocalFile: .... flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.kt' even though it exists. Please verify that this file has read permission and try again.
So, I run these two commands:
flutter clean
flutter pub cache repair
While running the second command, I noticed this new issue:
Failed to repair flutter_plugin_android_lifecycle 1.0.7. Error:
FileSystemException: Deletion failed, path = ...\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7' (OS Error: The system cannot find the path specified.
Then, following this Packages GET failes with The plugin flutter_plugin_android_lifecycle, I removed the .pub-cache folder in my flutter directory
After that, I run
flutter pub get
Finally, everything starts to work again.
i am a newbie in flutter, actually i am importing http.dart file after adding dependency "http: ^0.12.0" in pubspec.yaml , but as soon as i started importing http.dart file in main.dart and redirect to http.dart file , it shows empty there also the http.get(url) is unrecognized.
thats how i am importing http.dart file :-
import 'package:flutter/http/http.dart' as http;
and this is my pubspec.yaml:-
---
cupertino_icons: ^0.1.2
dependencies:
flutter:
sdk: flutter
description: "A new Flutter application."
dev_dependencies:
flutter_test:
sdk: flutter
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
flutter:
uses-material-design: true
name: flutter_app
shared_preferences: ^0.2.0
version: 1.0.0+1
any help would be appreciated, thanks in advance!
This is how you should import
import 'package:http/http.dart' as http;
This is how your pubspec.yaml be:
dependencies:
flutter:
sdk: flutter
http: any
Run $flutter upgrade to get latest flutter sdk
I am trying to use rxdart package for the first time in my Flutter app and I have added the package in yaml file, then I saved it and vscode automatically ran flutter packages get on project after that complete I tried to import the package with following line
import 'package:rxdart/rxdart.dart';
but the compiler doesn't recognize rxdart within the packages. which is causing the error in the app.
The following are my dependencies of pubspec.yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
rxdart: ^0.18.0
dev_dependencies:
flutter_test:
sdk: flutter
Update
Here is the repo for the project I am working on: https://www.github.com/touseefbsb/LoginStateful
You have to open the folder login_stateful_bloc and the error is in bloc.dart file where I am trying to import it.
You have to keep the indents :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
rxdart: ^0.18.0
I was having the same issue. Even after pub get, it didn't work. Then I simply restarted my IDE(Android Studio) and now it works.
this worked for me, make sure you putted the dependencies on
dependencies:
flutter:
not
dev_dependencies:
flutter_test:
if that make sense :/