我在flutter项目中使用VS Code。我刚刚编辑了pubspec.yaml以指向包的更高版本,它会自动运行'flutter packages get‘。在我的'/development//flutter/.pub-cache/hosted/pub.dartlang.org‘目录中,我可以看到这两个版本。但当我编译时,它看起来仍在使用旧版本。我尝试了各种方法,比如'flutter packages upgrade','flutter clean',等等,但都没有效果。查看两个包版本的源代码,我可以看到我希望在新版本中进行的更改。我如何指向新的包?谢谢。
更新:
没有更新的是“以太”包。我使用了3.0.0版本(方法需要2个参数),然后切换到3.1.0版本(方法需要3个参数)。但是使用3 arg调用进行编译会因为参数计数不正确而停止:
client.admin.personalSendTransaction(BigInt.parse(currentAddress), currentPassword,{});
[dart] Too many positional arguments: 2 expected, but 3 found. [extra_positional_arguments_could_be_named]然而,将鼠标悬停在方法调用上确实表明它需要3个参数:
personalSendTransaction(BigInt address, String passphrase, {BigInt to, BigInt data, int gas, int gasPrice, int value, int nonce, int condition, bool conditionIsTimestamp: false}) → Future<BigInt>pubspec.yaml:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
# Get package(s) for talking to ethereum node
# web3dart: '>=0.3.0'
ethereum: ^3.1.0
# read barcodes and QR codes
barcode_scan: ^0.0.3
# Generate a QR code
qr: ^1.0.1
# Display as actual symbol
qr_flutter: ^1.1.5
dev_dependencies:
flutter_test:
sdk: flutter在pubspec.lock中:
ethereum:
dependency: "direct main"
description:
name: ethereum
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"版本3.1.0是我想要使用的版本。
运行'flutter packages upgrade resolved‘会产生以下结果:
[Gregorys-iMac]:(gkd) ~/Programs/wine_track $ flutter packages upgrade resolved
Running "flutter packages upgrade" in .... 2.7s在包缓存中,我有两个:
/Users/gkd/development//flutter/.pub-cache/hosted/pub.dartlang.org/ethereum-3.0.0/lib/src/api/ethereum_api_admin.dart
/Users/gkd/development//flutter/.pub-cache/hosted/pub.dartlang.org/ethereum-3.1.0/lib/src/api/ethereum_api_admin.dart发布于 2020-05-20 22:45:43
您可以简单地在项目中运行flutter packages upgrade来升级所有包。此功能在flutter版本1.17中可用
发布于 2021-06-12 13:05:25
flutter pub升级版--主要版本
发布于 2020-06-26 10:48:34
我已经为此创建了一个python3脚本,您可以使用。此脚本仅生成最新的包名称和版本,必须复制并粘贴到pubspec.yaml文件中。
import yaml
import requests
from lxml import etree
from io import StringIO
def getNewVersion(pkg_name):
url = f'https://pub.dev/packages/{pkg_name}'
with requests.get(url) as req:
doc = etree.parse(StringIO(req.text), etree.HTMLParser()).getroot()
title = doc.xpath('//h2[@class="title"]')[0].text.strip()
return '^' + (title.split(' ')[1])
if __name__ == "__main__":
filename = 'pubspec.yaml'
new_map = None
with open(filename, 'r') as _f:
docs = yaml.load(_f, Loader=yaml.FullLoader)
deps = docs['dependencies']
for package_name, old_version in deps.items():
if package_name == 'flutter':
continue
last_version = getNewVersion(package_name)
print(f'{package_name}: {last_version}')https://stackoverflow.com/questions/53731646
复制相似问题