flutter pub 依赖冲突

  • 2021-12-25
  • Admin

由于 pub 线上插件  很可能依赖了 其他第三方pub 包;

而我们 自己有必须要依赖 某一个指定版本的  冲突的 pub 的时候;我们强制 统一版本

  1. Because chewie 1.2.2 depends on provider ^5.0.0 and no versions of chewie match >1.2.2 <2.0.0, chewie ^1.2.2 requires provider ^5.0.0.
  2. So, because bilibili depends on both chewie ^1.2.2 and provider 6.0.0, version solving failed.
  3. pub get failed (1; So, because bilibili depends on both chewie ^1.2.2 and provider 6.0.0, version solving failed.)

 pubspec.yaml 文件

  1. name: bilibili
  2. description: bilibili
  3. # The following line prevents the package from being accidentally published to
  4. # pub.dev using `flutter pub publish`. This is preferred for private packages.
  5. publish_to: 'none' # Remove this line if you wish to publish to pub.dev
  6. # The following defines the version and build number for your application.
  7. # A version number is three numbers separated by dots, like 1.2.43
  8. # followed by an optional build number separated by a +.
  9. # Both the version and the builder number may be overridden in flutter
  10. # build by specifying --build-name and --build-number, respectively.
  11. # In Android, build-name is used as versionName while build-number used as versionCode.
  12. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
  13. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
  14. # Read more about iOS versioning at
  15. # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
  16. version: 1.0.0+1
  17. environment:
  18. sdk: ">=2.12.0 <3.0.0"
  19. # Dependencies specify other packages that your package needs in order to work.
  20. # To automatically upgrade your package dependencies to the latest versions
  21. # consider running `flutter pub upgrade --major-versions`. Alternatively,
  22. # dependencies can be manually updated by changing the version numbers below to
  23. # the latest version available on pub.dev. To see which dependencies have newer
  24. # versions available, run `flutter pub outdated`.
  25. #强制解决依赖冲突
  26. dependency_overrides:
  27. provider: 6.0.0
  28. dependencies:
  29. flutter:
  30. sdk: flutter
  31. # The following adds the Cupertino Icons font to your application.
  32. # Use with the CupertinoIcons class for iOS style icons.
  33. cupertino_icons: ^1.0.2
  34. dio: ^4.0.4
  35. shared_preferences: ^2.0.11
  36. #图片 toast
  37. fluttertoast: ^8.0.8
  38. #图片 swiper
  39. flutter_swiper_null_safety: ^1.0.2
  40. #网格
  41. flutter_staggered_grid_view: ^0.4.1
  42. #图片淡入淡出
  43. transparent_image: ^2.0.0
  44. #图片本地缓存
  45. cached_network_image: ^3.2.0
  46. #下拉刷新
  47. pull_to_refresh: ^2.0.0
  48. #动画组件
  49. lottie: ^1.2.1
  50. #视频播放器
  51. chewie: ^1.2.2
  52. video_player: ^2.2.8
  53. #全屏插件
  54. orientation: ^1.3.0
  55. #设置状态栏颜色
  56. flutter_statusbarcolor_ns: ^0.4.0
  57. #状态管理
  58. # provider: ^5.0.0
  59. provider: 6.0.0
  60. # flutter_statusbarcolor_ns: ^0.4.0
  61. dev_dependencies:
  62. flutter_test:
  63. sdk: flutter
  64. # The "flutter_lints" package below contains a set of recommended lints to
  65. # encourage good coding practices. The lint set provided by the package is
  66. # activated in the `analysis_options.yaml` file located at the root of your
  67. # package. See that file for information about deactivating specific lint
  68. # rules and activating additional ones.
  69. flutter_lints: ^1.0.0
  70. # For information on the generic Dart part of this file, see the
  71. # following page: https://dart.dev/tools/pub/pubspec
  72. # The following section is specific to Flutter.
  73. flutter:
  74. # The following line ensures that the Material Icons font is
  75. # included with your application, so that you can use the icons in
  76. # the material Icons class.
  77. uses-material-design: true
  78. # To add assets to your application, add an assets section, like this:
  79. # assets:
  80. # - images/a_dot_burr.jpeg
  81. # - images/a_dot_ham.jpeg
  82. assets:
  83. #按照目录进行加载
  84. - assets/images/
  85. - assets/lottieAnimation/
  86. #按照单个问价进行加载
  87. # - assets/images/avatar.png
  88. # - assets/images/head_left.png
  89. # - assets/images/head_left_protect.png
  90. # - assets/images/head_right.png
  91. # - assets/images/head_right_protect.png
  92. # - assets/images/logo.png
  93. # An image asset can refer to one or more resolution-specific "variants", see
  94. # https://flutter.dev/assets-and-images/#resolution-aware.
  95. # For details regarding adding assets from package dependencies, see
  96. # https://flutter.dev/assets-and-images/#from-packages
  97. # To add custom fonts to your application, add a fonts section here,
  98. # in this "flutter" section. Each entry in this list should have a
  99. # "family" key with the font family name, and a "fonts" key with a
  100. # list giving the asset and other descriptors for the font. For
  101. # example:
  102. # fonts:
  103. # - family: Schyler
  104. # fonts:
  105. # - asset: fonts/Schyler-Regular.ttf
  106. # - asset: fonts/Schyler-Italic.ttf
  107. # style: italic
  108. # - family: Trajan Pro
  109. # fonts:
  110. # - asset: fonts/TrajanPro.ttf
  111. # - asset: fonts/TrajanPro_Bold.ttf
  112. # weight: 700
  113. #
  114. # For details regarding fonts from package dependencies,
  115. # see https://flutter.dev/custom-fonts/#from-packages
  1. #强制解决依赖冲突
  2. dependency_overrides:
  3. provider: 6.0.0

 强制 指定版本之后会有一个 警告!  一般忽略就可以

 

原文:https://blog.csdn.net/nicepainkiller/article/details/122143927

联系站长

QQ:769220720