3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

qnoteAdvent Calendar 2023

Day 13

【Flutter】Because every version of flutter from sdk depends on・・・version solving failed.バージョンエラーが出たときにやったこと

Last updated at Posted at 2023-12-12

Flutterで新しくライブラリを入れてpub getしたときに以下のエラーが出たので、やったことを解説します

Because every version of flutter from sdk depends on meta 1.8.0 and riverpod >=2.3.10 <3.0.0-dev.0 depends on meta ^1.9.0, flutter from sdk is incompatible with riverpod >=2.3.10 <3.0.0-dev.0.
And because hooks_riverpod >=2.4.9 <3.0.0-dev.0 depends on riverpod 2.4.9, flutter from sdk is incompatible with hooks_riverpod >=2.4.9 <3.0.0-dev.0.
So, because household depends on both flutter from sdk and hooks_riverpod 2.4.9, version solving failed.
pub get failed
command: "/Users/nakayamatakahito/fvm/versions/3.7.1/bin/cache/dart-sdk/bin/dart __deprecated_pub --directory . get --example"
pub env: {
  "FLUTTER_ROOT": "/Users/nakayamatakahito/fvm/versions/3.7.1",
  "PUB_ENVIRONMENT": "flutter_cli:get",
  "PUB_CACHE": "/Users/nakayamatakahito/.pub-cache",
}
exit code: 1

原因

ライブラリのバージョンと現在のSDKのバージョンとの互換性がなくてエラーが出てるのが原因っぽい

dependencies:
  flutter:
    sdk: flutter
  hooks_riverpod: 2.4.9

hooks_riverpodを最新バージョンで入れてたんですが、これが問題のようです

解決策

互換性のあるバージョンに変えるためには、まずバージョンを削除した状態でpub getします

dependencies:
  flutter:
    sdk: flutter
  hooks_riverpod: 

そしてpubspec.lockを見ると、インストール可能なバージョンでインストールされています

pubspec.lock
hooks_riverpod:
    dependency: "direct main"
    description:
      name: hooks_riverpod
      sha256: "117edbe7e5cfc02e31a94f97e2acd4581f54bc37fcda9dce1f606f8ac851ba24"
      url: "https://pub.dev"
    source: hosted
    version: "2.3.7"

この2.3.7をpubspec.yamlに記述して完了です

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?