flutter 导入依赖失败

时间:2021-07-05 10:31:05

标签: flutter flutter-dependencies

我从 git 克隆了一个项目。代码很久​​以前,似乎依赖项没有更新,所以我坚持依赖项的问题。我将每个依赖项更新到最新版本。这是我的 pubspec.yaml 代码:

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    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.3
  optimized_cached_image: ^2.0.1
  cached_network_image: ^3.0.0
  flutter_cache_manager: ^3.1.2 #for cached_network_image
  http: ^0.13.3
  provider: ^5.0.0
  connectivity: ^3.0.6
  dynamic_theme: ^1.0.1
  sembast: ^3.1.0+2
  path_provider: ^2.0.2
  intl: ^0.17.0
  shimmer: ^2.0.0
  url_launcher: ^6.0.9
  carousel_slider: ^4.0.0
  firebase_core: ^1.3.0
  firebase_messaging: ^10.0.3
  # firebase_auth: 0.16.0 # firebase_auth is for phone login
  flutter_webview_plugin: ^0.4.0
  firebase_auth: ^2.0.0
  flutter_native_admob: ^2.1.0+3
  google_sign_in: ^5.0.4
  flutter_facebook_login: ^3.0.0
  photo_view: ^0.11.1
  flutter_speed_dial: ^3.0.5
  dio: ^4.0.0
  multi_image_picker: ^4.8.1
  progress_dialog: ^1.2.4
  braintree_payment: ^1.2.4
  easy_localization: ^3.0.0
  launch_review: ^3.0.1
  package_info: ^2.0.2
  flutter_icons: ^1.1.0
  stripe_payment: ^1.1.3
  flutter_credit_card: ^2.0.0
  fluttertoast: ^8.0.7
  permission_handler: ^8.1.2
  apple_sign_in: ^0.1.0
  geolocator: ^7.2.0+1
  geocoder: ^0.2.1
  flutter_map: ^0.13.1
  latlong: ^0.6.1
  razorpay_flutter: ^1.2.6
  flutter_widget_from_html: ^0.6.1
  flutter_native_image: ^0.0.6
  group_radio_button: ^1.1.0
  flutter_datetime_picker: ^1.5.1
  flutter_paystack: ^1.0.5+1
  flutter_statusbar_manager: ^2.0.0
  
dev_dependencies:
  flutter_test:
    sdk: flutter

在运行 flutter pub get 命令后,我收到以下错误:

 Because easy_localization >=3.0.0-nullsafety depends on shared_preferences ^2.0.0-nullsafety and dynamic_theme 1.0.1 depends on shared_preferences ^0.5.0, easy_localization >=3.0.0-nullsafety is incompatible with dynamic_theme 1.0.1.
And because no versions of dynamic_theme match >1.0.1 <2.0.0, easy_localization >=3.0.0-nullsafety is incompatible with dynamic_theme ^1.0.1.
So, because fluttermultigrocery depends on both dynamic_theme ^1.0.1 and easy_localization ^3.0.0, version solving failed.
pub get failed (1; So, because fluttermultigrocery depends on both dynamic_theme ^1.0.1 and easy_localization ^3.0.0, version solving failed.)

1 个答案:

答案 0 :(得分:1)

在您的情况下使用 easy_localization: ^2.3.3 而不是 easy_localization:^3.0.0

这个错误的原因是你没有迁移到空安全。因此,您需要将所有包迁移到空安全或将所有包的版本更改为迁移到空安全之前的版本。