在 Flutter 中打印整个 Ethercan API 调用

The entire Ethercan API call being printed in Flutter

我试图只获取 API 呼叫响应的“结果”部分,但整个呼叫都在打印。

final balance = await etherscan.tokenBalance(address: myAddress, contractAddress: getAddresses());

print(balance.result); 

这是回复:

I/flutter ( 6425): api_url: https://api-rinkeby.etherscan.io
I/flutter ( 6425): query: {
I/flutter ( 6425):   "module": "account",
I/flutter ( 6425):   "action": "tokenbalance",
I/flutter ( 6425):   "apiKey": "*******",
I/flutter ( 6425):   "tag": "latest",
I/flutter ( 6425):   "contractaddress": "0x01BE23585060835E02B77ef475b0Cc51aA1e0709",
I/flutter ( 6425):   "address": "********"
I/flutter ( 6425): }
I/flutter ( 6425): response: {
I/flutter ( 6425):   "status": "1",
I/flutter ( 6425):   "message": "OK",
I/flutter ( 6425):   "result": "70000000000000000000"
I/flutter ( 6425): }
I/flutter ( 6425): 70000000000000000000

提前致谢!

打印看起来像是日志的最后一行(您只看到数字)另一个看起来像是包中的内部日志,您使用这个包有什么变化吗?

https://pub.dev/packages/etherscan_api

如果是,您是否像自述文件中看到的那样进行了初始化?

final eth = EtherscanAPI(
    apiKey: 'YourApiKey', // Api key
    chain: EthChain.ropsten, // Network/chain
    enableLogs: true // Enable Logging
  );

也许 enableLogs: true 属性 是导致日志显示的原因,如果是这种情况,请尝试将其更改为 false!