再會,
我是 Dart & Flutter 的初學者,并且有一個挑戰。
當滑鼠懸停在影像上時,它會將透明顏色與影像上的圖示重疊。
你可以在這里看到我想做什么:

以下是我正在嘗試的源代碼,
InkResponse(
highlightShape: BoxShape.rectangle,
containedInkWell: true,
onHover: (isHovering) {
if (isHovering) {
// maybe input something here
} else {
// maybe input something here
}
},
onTap: () => {showMyDialog()},
child: Ink.image(
width: 350.0,
height: 280.0,
fit: BoxFit.cover,
image: Image.asset('images/technology.png').image,
),
)
不幸的是,我不知道如何解決它。
你能給我一個提示或解決方案嗎?
這將不勝感激。
uj5u.com熱心網友回復:
首先定義一個像這樣的變數:
bool isHovered = false;
然后在您的構建方法中將您的InkResponse小部件更改為:
InkWell(
onHover: (isHovering) {
setState(() {
isHovered = isHovering;
});
},
onTap: () => {},
child: Stack(
children: [
Image(
width: 350.0,
height: 280.0,
fit: BoxFit.cover,
image: Image.asset('images/technology.png').image,
),
isHovered
? Container(
width: 350.0,
height: 280.0,
color: Colors.red.withOpacity(0.4),
child: Icon(
Icons.add,
size: 34,
color: Colors.white,
),
)
: SizedBox(),
],
),
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/516797.html
標籤:扑镖颤振布局
上一篇:如何在另一個或替代中添加一個類
