Sample code as an example
class SO extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[X(), X(), X(), X()],
),
),
),
);
}
}
class X extends StatefulWidget {
@override
_XState createState() => _XState();
}
class _XState extends State<X> {
bool isElevated = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
print('_XState.build() tap');
setState(() {
isElevated = !isElevated;
});
},
child: Material(
elevation: isElevated ? 40 : 0, //change as needed
animationDuration: Duration(milliseconds: 400), //change as needed
child: Container(
width: 100,
height: 100,
color: Colors.red,
),
),
);
}
}
您可以尝试将堆栈作为所有其他小部件的父小部件。
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.