在卡片小工具中添加容器时,卡片的提升不会应用于卡片的顶部。
Card(
elevation: 10,
shadowColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
child: Column(
children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// widget goes here
],
),
),
SizedBox(
height: 20,
),
// some more widgets
],
),
);发布于 2021-12-01 12:42:56
考虑使用容器装饰而不是卡片提升
return Container(
margin: EdgeInsets.all(50),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.green.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
),
child:Column(), //your widget here
)发布于 2021-12-01 17:07:15
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Align(
alignment: AlignmentDirectional.topCenter,
child: Container(
height: 200,
width: 200,
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
color: Colors.cyan,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("SOMETHING")
// widget goes here
],
),
),
],
),
color: Colors.orange,
elevation: 10,
shadowColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
),
),
)),
);
}

https://stackoverflow.com/questions/70179989
复制相似问题