How to solve problem of git cloning while running flutter pub get for a dependency - flutter

I am currently working on an old flutter project. I want to install the necessary dependencies so that i can start making changes.
Now when i run the flutter pub get command, i get a certain error which is not explaining how to solve it.
pub get failed (server unavailable) -- attempting retry 10 in 64 seconds...
Git error. Command: git clone --mirror git://github.com/tekartik/platform.dart C:\src\flutter2\.pub-cache\git\cache\platform.dart-6f0f0462856ed9b1246d3c594e824b1b2d81f000
stdout:
stderr: Cloning into bare repository 'C:\src\flutter2.pub-cache\git\cache\platform.dart-6f0f0462856ed9b1246d3c594e824b1b2d81f000'...
fatal: unable to connect to github.com:
github.com[0: 140.82.121.3]: errno=Unknown error
I think the point reached for downloading the dependency and it is not showing me where i can change from git:// to git#github
Below is a code snippet of the pubspec.yaml file where the dependency is to be installed
tekartik_app_platform:
git:
url: git#github.com:tekartik/app_flutter_utils.dart.git
ref: null_safety
path: app_platform
version: '>=0.1.0'
I am trying to get help on how to solve it because i only just got the code which is an old code and so am not sure where to go and make the fix.
Thank you alot in advance.

Try changing it to:
git:
url: https://github.com/tekartik/app_flutter_utils.dart
path: app_platform
ref: null_safety
More info on the packages can be found under: Dependencies on unpublished packages
https://docs.flutter.dev/development/packages-and-plugins/using-packages

I managed to find the solution. The ref value the project was using is null safety which still uses "git://" which is not being used by github anymore and so that is where the error is coming from.
So i changed to
tekartik_app_platform:
git:
url: git#github.com:tekartik/app_flutter_utils.dart.git
ref: dart2_3
path: app_platform
version: '>=0.1.0'

If this is the case for adding the plugin dependecy in flutter by git reference
Make sure you have public access for the same repository. if private then go to bottom of general setting and make it public.

Related

Importing packages from GitHub in pubspec yaml, requires pubspec.yaml file which isnt in the repository

I have issues using flutter pub get with a repository package in my pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
flutter_stripe:
git:
url: https://github.com/flutter-stripe/flutter_stripe.git
ref: poc-use-expensive-androidview
Following the steps provided https://dart.dev/tools/pub/dependencies#git-packages.
However, I am getting the error
Could not find a file named "pubspec.yaml" in https://github.com/flutter-stripe/flutter_stripe.git 7934151fefed73c6a22c253de3a1f1c9d46decc2.
pub get failed (1; Could not find a file named "pubspec.yaml" in https://github.com/flutter-stripe/flutter_stripe.git 7934151fefed73c6a22c253de3a1f1c9d46decc2.)
I have no idea what I am suppose to put for the pubspec.yaml which is not present in the repository. And it works fine if you call the package as it is using flutter pub add flutter_stripe.
The reason I am required to use an unofficial branch is because one of the fields provided by the package is not working correctly, and the suggested solution is to use this branch.
Sorry, my bad, I didnt know that the root of the Hosted package isn't the final path. I was required to add a path to the packages, which can then be found in ./packages/stripe.
flutter_stripe:
git:
url: https://github.com/flutter-stripe/flutter_stripe.git
ref: poc-use-expensive-androidview
path: ./packages/stripe
For anyone who has the same issue as me... or maybe i'm just noob
If you look at the packages of the git project you can see more then one package: https://github.com/flutter-stripe/flutter_stripe/tree/main/packages
You have to choose the package(s) you need.

Why is this "illegal url" error appearing when running flutter doctor?

I have installed a new version of flutter in my macOS. But when trying to run
flutter doctor I get this
Downloading Dart SDK from Flutter engine <<<<<<< HEAD
05e680e202af9a92461070cb2d9982acad46c83c
=======
d3ea636dc5d16b56819f3266241e1f708979c233
>>>>>>> 18116933e77adc82f80866c928266a5b4f1ed645...
curl: (3) URL using bad/illegal format or missing URL
Failed to retrieve the Dart SDK from: https://storage.googleapis.com/flutter_infra_release/flutter/<<<<<<< HEAD
05e680e202af9a92461070cb2d9982acad46c83c
=======
d3ea636dc5d16b56819f3266241e1f708979c233
>>>>>>> 18116933e77adc82f80866c928266a5b4f1ed645/dart-sdk-darwin-x64.zip
If you're located in China, please see this page:
https://flutter.dev/community/china
Is there a known fix for this? I have looked for an answer, but they're mostly targeted towards Windows.
navigate to git folder
in git console: (be aware local changes are dismissed!)
git fetch --all
git reset --hard origin/master
This is what worked for me - deleted the flutter folder and replaced it with one from the official flutter webpage

How to use a fork of flutter.widgets in a flutter project?

Found this article, that seems like it would give sufficient instructions for using forked versions of many pub packages.
However, the package I want to fork (scrollable_positioned_list) is a part of a the flutter.widgets repository, which is not a package itself, but a collection of packages.
I've been able to fork and modify the package, my trouble is being able to use my fork in my project.
I've tried the obvious:
dependencies:
flutter:
sdk: flutter
scrollable_positioned_list:
git:
url: https://github.com/bendelonlee/flutter.widgets
This causes flutter pub get to fail with the error:
pub get failed (1; Could not find a file named "pubspec.yaml" in https://github.com/bendelonlee/flutter.widgets 1f2935687390a9315c3336007a4eac00563365a4.)
Indeed, there is no pubspec.yaml in the root of that directory, though there is one nested in the package.
I've also tried using the url of the package inside the repository
scrollable_positioned_list:
git:
url: https://github.com/bendelonlee/flutter.widgets/tree/master/packages/scrollable_positioned_list
This fails with an error complaining that the repository isn't found:
fatal: repository 'https://github.com/bendelonlee/flutter.widgets/tree/master/packages/scrollable_positioned_list/' not found
The path argument should be added just as the official docs state:
Pub assumes that the package is in the root of the Git repository. To specify a different location in the repo, use the path argumen
In your specific cace this would be
scrollable_positioned_list:
git:
url: https://github.com/bendelonlee/flutter.widgets
path: packages/scrollable_positioned_list

Unable to update flutter

I am trying to run commands like flutter upgrade and flutter doctor and even when I try to check for channel flutter channel but it is showing me just these particular set of commands -
Downloading Dart SDK from Flutter engine <<<<<<< HEAD
2dce47073a378673f6ca095e91b8065544c3a881
=======
91c9fc8fe011352879e3bb6660966eafc0847233
>>>>>>> d79295af24c3ed621c33713ecda14ad196fd9c31...
curl: (3) URL using bad/illegal format or missing URL
Failed to retrieve the Dart SDK from: https://storage.googleapis.com/flutter_infra_release/flutter/<<<<<<< HEAD
2dce47073a378673f6ca095e91b8065544c3a881
=======
91c9fc8fe011352879e3bb6660966eafc0847233
>>>>>>> d79295af24c3ed621c33713ecda14ad196fd9c31/dart-sdk-darwin-x64.zip
If you're located in China, please see this page:
https://flutter.dev/community/china
If anyone has faced a similar problem or has any idea what to do...please help.
It looks like you have merge conflict markers in your Flutter SDKs internal files (for example bin/internal/engine.version).
You may be able to fix this with flutter ugprade --force or by following the instructions here:
https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted
Run the following commands in the Flutter install directory:
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
change engine.version CRLF -> LF
for more info you can look at this
https://github.com/flutter/flutter/issues/35921

Flutter - Overridden dependencies

After running "flutter pub get", I got this error:
Warning: You are using these overridden dependencies:
! path 1.6.4
That's not an issue. That happens because you (or any other transitive dependency) may be overriding some dependency that you are already using. For example, if you are using path: 0.X.X and some other dependency use dependency_overrides to make sure that is using path: 1.6.4, it will present you that message.
Overall, you shouldn't have to worry with that and sometimes it is actually required in order to some dependencies work all together.
Please give more details so that i can answer it better. Attach your pubspec.yaml.
But now i can tell you some methods which should work..
first of all see if you are using the latest version of all dependencies or not then:
try:
restarting your ide
flutter clean
if these two don't work then at last try
flutter pub cache repair
I encountered the same error after cloning a flutter repository. I initially mistook the error for being a build issue when it's just a warning that won't stop your app from running.
I solved the build issue I was having with the freshly cloned project by running this command inside the app's root directory: flutter pub run build_runner build