Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Usage in Dart app without flutter #61

Closed
Matslom opened this issue May 28, 2022 · 7 comments
Closed

Usage in Dart app without flutter #61

Matslom opened this issue May 28, 2022 · 7 comments

Comments

@Matslom
Copy link

Matslom commented May 28, 2022

Hello,
I'm new to Dart, maybe there is something that I'm missing.
I have pure Dart app and wanted to require your package. The readme says that this package should work in dart but because of

environment:
  sdk: ">=2.17.0 <3.0.0"
  flutter: ">=3.0.0"

I'm not able to update dependencies because my app is not a flutter app.

Is there a way that I can add this package to app that is not a flutter app?

@SkinnyMind
Copy link
Owner

I am able to update dependencies in dart app without any problem.

What i did was:

  • Created new dart cli application with dart create gittest
  • Added libgit2dart as dependency in pubspec.yaml:
    dependencies:
      libgit2dart: ^1.1.0
  • Got dependencies with dart pub get (if you are using VSCode after editing pubspec.yaml and saving it, it should also get dependencies without any problem)

@Matslom
Copy link
Author

Matslom commented May 28, 2022

Thanks for the reply.
So, thats odd. Its almost clear dart project. I have pubspec like this

environment:
  sdk: '>=2.16.2 <3.0.0'

dependencies:
  args: ^2.0.0
  shelf: ^1.1.0
  shelf_router: ^1.0.0
  libgit2dart: ^1.1.0

and after dart pub get
I'm getting

Resolving dependencies...
Because globox depends on libgit2dart >=1.1.0 which requires the Flutter SDK, version solving failed.

Flutter users should run `flutter pub get` instead of `dart pub get`.

My dart version

dart --version
Dart SDK version: 2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "macos_x64"

@SkinnyMind
Copy link
Owner

And what happens if you run flutter pub get?

@Matslom
Copy link
Author

Matslom commented May 28, 2022

Currently I don't have flutter installed so i cannot check that.
I've searched for some libs at pub.dev that are listed as for Dart and Flutter, and every package have listed only sdk in environment section.
If I understand correctly what says https://dart.dev/tools/pub/pubspec#sdk-constraints I have to install flutter to use that package.

@SkinnyMind
Copy link
Owner

Ok, I thought you have Flutter installed. I guess you have to use flutter pub get even if you want to use it with Dart cli application.
It's probably related to dart-lang/pub#2606, since package also provides support for Flutter applications.

Please reply with result, after installing Flutter. I believe that'll fix the issue.

@Matslom
Copy link
Author

Matslom commented May 28, 2022

I don't really need flutter for now.
So instead of installing flutter, I've forked repo, removed flutter dependency and added

dependency_overrides:
  libgit2dart:
    git:
      url: https://github.com/Matslom/libgit2dart

to the pubspec. Looks like it's working fine.

@SkinnyMind
Copy link
Owner

Sure, that'll work :)

As a side note, if you'll install Flutter, the Dart SDK is bundled with it, so no need to have separate installation of Dart.

I'm closing issue, since it appears to be resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants