我有以下简单的 const { ethers } = require("ethers");
const walletAddress = "My_own_address";
const wethErc20Address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
const uniErc20Address = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984";
const uniswapRouterAbi = [
"function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)",
];
async function buyListedTokenWithEth(
amountEthFloat,
uniswapRouterAddress,
provider
) {
const wallet = new ethers.Wallet(Buffer.from(privateKey, "hex"));
const signer = wallet.connect(provider); //provider is Infura https ROPSTEN url
const exchangeContract = new ethers.Contract(
uniswapRouterAddress,
uniswapRouterAbi,
signer
);
const ethAmount = ethers.utils.parseEther("0.1");
const tx = await exchangeContract.swapExactTokensForTokens(
ethAmount,
0,
[wethErc20Address, uniErc20Address],
walletAddress,
createDeadline(), // Math.floor(Date.now() / 1000) + 20
createGasOverrides() // { gasLimit: ethers.utils.hexlify(300000), gasPrice: gasPriceWei }
);
console.log("https://ropsten.etherscan.io/tx/" + tx.hash);
}
文件,其中包含 4 张图像的 Gridview:
main.dart
在第一个 import 'package:flutter/material.dart';
import 'theme/config.dart';
void main() => runApp(_MyApp());
class _MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: configTheme,
home: Scaffold(
body: GridView.count(
crossAxisCount: 2,
children: <Widget>[
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
height: 100,
),
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
),
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
),
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
),
],
),
),
);
}
}
元素中,我应用了 Image
但这会被忽略(无论值是什么)。
如何解决这个问题,以便我可以应用任何高度?
答案 0 :(得分:0)
Scaffold(
body: new Container(
child: new GridView.count(
crossAxisCount: 2,
controller: new ScrollController(keepScrollOffset: false),
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: <Widget>[
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
height: 100,
),
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
),
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
),
Image.network(
'https://static01.nyt.com/images/2020/06/30/business/30india-tech-1/30india-tech-1-articleLarge.jpg?quality=75&auto=webp&disable=upscale',
fit: BoxFit.cover,
),
],
),
),
);