简体   繁体   English

在 flutter 应用程序中添加提供程序 package 时出错

[英]Error when add Provider package in flutter app

I want to add Provider package in my flutter app, but has error like follow image:我想在我的 flutter 应用程序中添加提供程序 package,但出现如下图所示的错误:

flutter pub pub add provider

在此处输入图像描述

This link don't solve it这个链接不能解决

In your package's pubspec.yaml add this line like below.在您的包的pubspec.yaml 中添加此行,如下所示。 Then run pub get/pub upgrade :然后运行pub get/pub upgrade

dependencies:
  provider: ^5.0.0

Note: Indentation must be considered.注意:必须考虑缩进。 Not valid无效

dependencies:
provider: ^5.0.0

This error is caused due to versioning error.此错误是由于版本控制错误引起的。

In your pubspec.yaml file在您的 pubspec.yaml 文件中

dependencies:
    provider: 

Leave the version blank, it will automatically select the best one according to the other packages.将版本留空,它将根据其他软件包自动 select 最好的一个。 After this run flutter pub get之后运行flutter pub get

I solved it:) The name of your project can not be equal to package name.我解决了:)您的项目名称不能等于 package 名称。 The name of my project is provider and that is compiler gave an error.我的项目名称是提供者,即编译器出错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM