I want to add this package in flutter project. Why this charts? Because it´s have a negative bars
I try to add something like this
charts_flutter:
git:
url: git://github.com/jeroentrappers/charts.git
path: charts/charts_flutter/
name: charts
ref: master
But return
Could not find a file named "charts/charts_flutter/pubspec.yaml" in
git://github.com/jeroentrappers/charts.git
ee7a2110386f7b3e6476eb9ff815c11a65875195.
So what is the correct way to add this type git packages?
This should work
charts_flutter:
git:
url: git://github.com/jeroentrappers/charts.git
path: charts_flutter
ref: master
The path is relative to the repository and charts_flutter is a root directory in the repository.
name is redundant if it's the same as the dependency itself.
Update
In the GitHub repo the charts_flutter pubspec.yaml is set up for development and can't be used as Git dependency because it contains a path dependency
dependencies:
charts_common:
path: ../charts_common/
That this dependency can not be overridden by dependency_overrides looks like a pub bug to me.
dependencies:
charts_flutter:
dependency_overrides:
charts_common:
git:
url: git://github.com/jeroentrappers/charts.git
path: charts_common
ref: master
charts_flutter:
git:
url: git://github.com/jeroentrappers/charts.git
path: charts_flutter
ref: master
A workaround would be to clone the GitHub repo to a local directory and use a path dependency instead.
dependencies:
charts_flutter:
path: ../../charts/charts_flutter
Related
I want to import a package's specific pull request, for example, this one. I wish I could do:
dependencies:
permission_handler:
git: https://github.com/Baseflow/flutter-permission-handler/pull/967
You can need to use ref and give it the value of the commit.
dependencies:
permission_handler:
git: https://github.com/Baseflow/flutter-permission-handler.git
ref: a73ec3f5164bbc21ad0a9748ab58e862fb80b12f
Please check this format.
dependencies:
permission_handler:
git:
url: https://github.com/Baseflow/flutter-permission-handler.git
ref: a73ec3f5164bbc21ad0a9748ab58e862fb80b12f
I want to use the 9.0.0-dev version of the hydrated_bloc package.
If I run pub get on my pubspec.yaml:
dependencies:
flutter:
sdk: flutter
hydrated_bloc: ^9.0.0-dev.3
I get the message Latest available version is: 8.1.0
How can I get the prereleases?
That is the version found on pud.dev.
If you want to use the latest dev package you could point to the github repo instead
hydrated_bloc:
git:
url: https://github.com/felangel/bloc.git
ref: master
path: packages/hydrated_bloc/
I need get package form github
I know how to do it
dart_vlc:
dart_vlc_ffi:
git:
url: https://github.com/alexmercerind/dart_vlc.git
path: ffi
ref: master
But my problem
it's get old version .. I need latest version
and I have one questions
how I can select version from tags (like use dart_vlc v0.1.8 from github)
This issue is fixed in the latest version of dart_vlc.
Mention dependencies as follows in your pubspec.yaml to use the GitHub version of the dart_vlc in your Flutter project.
dependencies:
dart_vlc:
git:
url: https://github.com/alexmercerind/dart_vlc.git
ref: master
dependency_overrides:
dart_vlc_ffi:
git:
url: https://github.com/alexmercerind/dart_vlc.git
ref: master
path: ffi
In Flame we have a monorepo with Flame and its bridge packages and all of the bridge packages has Flame as a path dependency (not when they are released). It doesn't seem to be possible to depend on our main branch and on a bridge library on the main branch at the same time, I have this in the pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
flame:
git:
url: git#github.com:flame-engine/flame.git
path: packages/flame
ref: main
flame_fire_atlas:
git:
url: git#github.com:flame-engine/flame.git
path: packages/flame_fire_atlas
ref: main
dependency_overrides:
flame:
git:
url: git#github.com:flame-engine/flame.git
path: packages/flame
ref: main
When doing pub get I get:
Error on line 15, column 11: Invalid description in the "flame_fire_atlas" pubspec on the "flame" dependency: "../flame" is a relative path, but this isn't a local pubspec.
╷
15 │ path: ../flame
│ ^^^^^^^^
╵
pub get failed (65; ╵)
which indicates that the dependency_override wasn't used, is it not possible to override path dependencies?
Apparently this is a bug in pub, the only way to solve it for now is to clone the dependencies that you need to the path that the packages expect them.
So in this case I would have to clone the branch of flame that I want to use to ../flame, in relation to the projects pubspec file.
see this this solution it may help you.
I need to use the latest source code of a package and the latest source hasn't been published yet.
What should I write into pubspec.yaml to get a package in Github?
The code below doesn't work. It doesn't download the package and I can't import it into my source code
dependencies:
flutter:
sdk: flutter
carousel_pro:
git:
url: https://github.com/jlouage/flutter-carousel-pro.git
Example of pubspec.yaml
Dependency with the specific branch:
dependencies:
flutter:
sdk: flutter
carousel_pro:
git:
url: https://github.com/jlouage/flutter-carousel-pro.git
ref: main # branch name
Dependency with the specific commit:
dependencies:
flutter:
sdk: flutter
carousel_pro:
git:
url: https://github.com/jlouage/flutter-carousel-pro.git
ref: ea12e41 # commit hash
Example of a file importing the package:
import 'package:carousel_pro/src/carousel_pro_widgets.dart';
import 'package:flutter/material.dart';
class NewsCarousel extends StatelessWidget {
#override
Widget build(BuildContext context) {
return SizedBox(
height: 200.0,
child: WidgetCarousel(
autoplay: false,
pages: [],
),
);
}
}
Note: If your IDE doesn't see the package, try to restart it.
The above answers are correct but I have added some examples.
So to use pub/package/lib without publishing on pub.dev :
1. Local - Save in some local folder
dependencies:
library_name:
path: /path/to/library_name
2. Hosted - Pushed on Github, Gitlab etc.
dependencies:
library_name:
git: https://github.com/username/library_name
Or to target exact branch
dependencies:
library_name:
git:
url: https://github.com/username/library_name.git
ref: dev #branch name
Or to target exact commit
dependencies:
library_name:
git:
url: https://github.com/username/library_name.git
ref: e234072340 #commit reference id
Where 'library_name' has to be the same as the 'name' declared in pubspec.yaml of that pub.
I will show this use case, where you want to access a specific folder in a branch other than main/master:
amplify_flutter:
git:
url: git://github.com/aws-amplify/amplify-flutter.git
ref: null-safety-master
path: packages/amplify_flutter/
The above didn't work for me but changing the url to use https did:
dependencies:
flutter:
sdk: flutter
flutter_tflite:
git:
url: https://github.com/qookit/flutter_tflite.git
ref: main
"main" is the name of the branch I was interested in using.
The first time I ran 'flutter pub get' it opened up a browser window to ask me for my git credentials too.
Here is one Example
audio_service:
git:
url: https://github.com/kaushikgodhani/audio_service.git
ref: minor #branch name
path: audio_service #Folder Path on Github
you can use path if your package no the whole repository
geocoding:
git:
url: https://github.com/abdullahalamodi/flutter-geocoding.git
path: geocoding #refers to flutter-geocoding/geocoding
What's more, you can also use tag if you need:
private_view:
git:
url: git#github.com:xxx/private_view.git
ref: 0.0.2 # tag