is there a way to make a widget (ex. a button) visible only on hover? I want to make a way to show the edit button on the image just when image is hovered.
Stack(
children: <Widget>[
Image.asset(
'assets/profileimg/empty.jpg',
width: 110.0,
height: 110.0,
),
Positioned(
bottom: -2,
left: 5,
child: RaisedButton(
child: Text('Edit...'),
onPressed: null,
),
),
],
),
Thank you.
place this code inside your StatefulWidget
widget:
bool showEditButton = false;
Widget build(BuildContext context){
return Stack(
children: <Widget>[
InkWell(
onTap: ()=>setState(()=>showEditButton = true),
child: Image.asset(
'assets/profileimg/empty.jpg',
width: 110.0,
height: 110.0,
),
),
if(showEditButton)
Positioned(
bottom: -2,
left: 5,
child: RaisedButton(
child: Text('Edit...'),
onPressed: null,
),
),
],
);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.