在卡片小部件內添加容器時,卡片的高度不會應用于卡片頂部。
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
],
),
);
uj5u.com熱心網友回復:
考慮使用 Container 裝飾而不是 Card 高程
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
)
uj5u.com熱心網友回復:
@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://www.uj5u.com/ruanti/371762.html
