【笔记】Flutter的Card卡片组件

前言

Flutter的Card卡片组件学习笔记

Card卡片组件

shape:指定卡片形状

borderRadius:指定圆角

elevation:指定阴影深度
shadowColor:指定阴影颜色
color:指定背景颜色
margin:指定边距

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'package:flutter/material.dart';

void main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("文本内容"),
),
body: const App(),
),
));
}

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
return ListView(
children: [
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)
),
elevation: 10,
shadowColor: Colors.black,
color: Colors.red,
margin: const EdgeInsets.all(10),
child: const Text(""),
),
const Card(
child: Text(""),
)
],
);
}
}

完成

参考文献

哔哩哔哩——筱筱知晓